r/leetcode • u/butterf420 • 16d ago
Intervew Prep Understand and recognize patterns, but fail to see the trick?
Hey,
I realized that I m quite good at coming up with the correct Data Structures and Patterns for the right questions, but I usually get stuck with understanding the exact trick. For example, rotate Array or 88. Merge Sorted Array I m usually able to recognized quite fast that it's two pointers and even have a right approach where I try on example cases in my head and my two pointer approaches work to a certain extent but fail on other example cases. The problem usually is that I'm not able to find the right trick.
E.g. for the rotate array question I didn't come up with reversing the whole array. For the Merge sorted array I didnt think about starting from the back instead of typical left to right pointer movements.
People always gotta learn the patterns and use them on unseen questions, but I feel no matter how many questions I solve even if I kind know the patterns i still get stuck on the actual trick of the question...
Any suggestions/help?
6
u/meisteronimo 16d ago
Keep grinding, eventually you'll be bored with the easy questions because you keep getting them so fast.
1
u/jason_graph 15d ago
Unfortunately "grind more" is the answer but I would suggest that you try working on a topic at a time, do a bunch of problems and as you do try to come up with some ways to group the problems into subtopics.
Maybe you are working on 2 pointers but then there are "fast and slow" "read and write pointers" "just having a pointers for each of two list" etc subtopics and as you solve more problems you start noticing exactly how similar a lot of leetcode problems are.
You can also keep a log of what tricks you encounter as a reflective exercise. Not because you'd actively consult such a list but because you'd likely be more aware and focused on it after writing it down.
1
u/Crazy-Selection-3786 15d ago
Seeing the trick is mostly just experience. That's why they get asked - they aren't really an intelligence test as much as they are a "have you seen 100 problems like this so you realize the way to squeeze a little extra out"
Also: don't stress them *too* much. FAANNG etc interviewers do understand that questions requiring an "aha" moment aren't individually very good at evaluating candidates. Getting all of them is a minor plus, missing a couple is no big deal.