r/learnprogramming • • 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

26 comments sorted by

View all comments

10

u/6a70 8h ago • Heartwarming

Anytime I find a new problem I'm stuck
Because I never saw that before

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.

•

u/dhananjai_31 23m ago

Na bro I'm not actually remembering solutions but I'm remembering the pattern i find in the problem And whenever I encounter a problem which I didn't do or never saw I stuck Because I'm unable to create my own logic

•

u/6a70 15m ago

ok: while I disagree with your evaluation, please read beyond the first sentence of my comment

•

u/dhananjai_31 13m ago

Tq bro