After trying to figure out a balance between the two for almost a year, I have started using a simple time bound technique. Whenever I am faced with a new problem I try to come up with my own solution for max 20-25mins. If I am not able to come up with a solution I seek help of google or stackoverflow and if I am able to come up with a solution I still google or go to stackoverflow for checking whether a better solution exists. This not only helps me develop my problem solving skills but also helps me to come up with efficient solutions faster. Now the reason to keep the time to 20-25 mins is because I work as software engineer in the industry and not just as programmer or developer and a critical aspect of software engineering is to finish your projects within set deadlines in the most optimum way possible.Now this time limit might not be the best one for each purpose but we can set our own based on our field of work.
Initially as a junior developer I used to spend a lot of hours trying to solve problems myself and sometimes that used to create hurdles in project life cycle. Gradually I realized that pondering over minute problems for such a long time might not always be useful and eventually I started working in a time bound manner which greatly increased my focus and sort of gamified my daily coding activity by slowly trying to reduce that time limit every time.