r/learnprogramming • u/dhananjai_31 • 9h ago
How to improve logical thinking in programming
Hey
I'm 23m working professional,
Yesterday at the office my team lead said he found a pattern in my work
He said I'm mugging up patterns and not thinking logically.
Well I do codeforces , leetcode, hacker rank to improve my programming skills but I understood that he was right
All I do is find a pattern in the problem and try to solve it
Anytime I find a new problem I'm stuck
Because I never saw that before
How to come up with my own solution?? How to improve problem solving and logical thinking???
Open to all the suggestions:)
22
Upvotes
View all comments
10
u/6a70 8h ago •
This indicates that you're actually just remembering solutions.
You need to practice brute forcing things. And if the first solution you come up with isn't brute force, you still need to find out how to brute force it.
Go to TwoSum and brute force it—yes, the obvious n^2 solution. Then find the other n^2 solution that involves "inspecting the numbers we've already seen". Then take that and optimize that lookup with a hash table.
That's the approach—always brute force first. All of the solutions you come across in LeetCode are direct optimizations on brute force.