Show topics
Misc.

# Strategies to leetcode problems

Goldman Sachs xTy
Mar 14

Hey guys, I usually face difficulties when approaching completely new problem and get stuck eventually.

For eg.

https://leetcode.com/problems/maximal-rectangle/description/

My thought process looking at this problem:

- hmm dfs?
- but how do I track equal bounds on opposite side?
- maybe dfs does not work after all..
- oh maybe first store all locations of “1” in a hashmap with index. In next iteration, start from valid “1” location then check 4 directions with continuous “1” until we encounter “0”. Distance would be relative from starting position.
- hmm but how do I keep track of equal bounds..

After some time I literally freeze and give up.
How do you run algorithms in your mind efficiently?

I have good grasp on all popular algorithms, but I have issues in correctly choosing and applying them on a never seen problem.

What does your thought process look like when you see this kind of problem?

read the answer and memorize it. try to reduce the number of the "never seen questions" is the most efficient way for the interview.
Mar 146
• Qualcomm dynasty001
This actually works. I have started keeping notes using “anki” as well.
Mar 14
• New Leetup
I strongly disagree with this strategy. Memorization does not scale one you do 500+ questions. Focus on improving your problem solving skills not memorizing.
Mar 14
• Qualcomm dynasty001
I think he doesnt mean “memorization” per se. Its like when yiu do one thing so many times , it just gets imprinted in your memory. This is basically learning a pattern. Same reason people use “spaced repeatition” to remember things.
Mar 14
• New Leetup
Dude read his post he just says “read the answer and memorize it”. That’s not solving the question, you don’t get better that way. It is however the most effective way to study if you’re short on time. Still doesn’t scale.
Mar 14
• Qualcomm dynasty001
Yeah i gave him the benefit of doubt that he really didnt mean “memorize it” . How d fck can one memorize 200+ LC questions lol
Mar 14
• Sapient / Enggeek007more
@dynasty001 it's true. interviews are not der to solve the problem they are to check your coding speed. only memorization work. They asked me Hard on the phone and gave 30 mins to solve.
Yesterday
• Goldman Sachs abcdeaa
You should know largest histogram in an array to solve this one
Mar 140
• Amazon jessica22
^This. (And then you take their site down when the problem is outside of your “knowledge”)
Mar 140
I solved this question at an onsite by reducing it to the “largest rectangle in a histogram” problem.
Mar 143
• Salesforce exitways
So if you didn’t know largest rectangle in histogram problem, do you think you would have still solved it? Thanks!

P.s. is your nickname reference to Zerg SC player?
Mar 14