i ve just tried to do coding bat exercise. There are posted solutions to the problem i tried to solve.However, I was stubborn, i ignored them and tried to code it up my own way(basically reinventing my own wheel - square,bad working wheel). After 4 hours it looks nasty and fails some tests. Now i realize that my logic was totally wrong and wasteful. So the question :When do you start to give up solving problem your own way(reinventingthe wheel) and start to look around to see other solution?  How long should a developer be 'stubborn' in trying to find his 'unique' or complicated solution? When do you give up and begin to search foranother logic?
Give advice from experienced to beginner programmer on reinventing my wheel(solution)
efficiency
I usually follow below methodology when it comes to scenarios that you are facing:Get the root cause of problem for the solution that you are developing, it is not necessary that all your code logic is waste if the solution is not achieved. If you properly get the root cause then you are able to think on the new logic that can be plugged in to overcome root cause else at this position you can search online for help on that particular root cause. This way you will narrow down your searching & it will be manageable.Time to struggle for the solution really depends on two factors - deadlines if any And if no deadlines then till you get saturated. Usually time of around one day for a genuine issue is good enough to start re-thinking on some other approach. There are some instances where even after searching a lot on some particular problem there is no suitable solution found at that time the problem resolution may take up to a week also wherein you have to spend time on thinking out of the box solutions which have been never faced by anyone else till now. For example solving the issue of memory leakage from a Java 3D applet hosted on tomcat using web start.I guess above points covers answers to your 3 questions to some extends.