Hey guys, I usually face difficulties when approaching completely new problem and get stuck eventually.
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?
I have facebook onsite coming up in 2 weeks. Please help. :)
- Cadence tigerkread the answer and memorize it. try to reduce the number of the "never seen questions" is the most efficient way for the interview.
- I solved this question at an onsite by reducing it to the “largest rectangle in a histogram” problem.
- Citrix Systems pedaI think for Facebook you need to memorize and practice a lot. And lot depends on luck. I honestly feel they’re are very few intelligent ppl who can solve any problem at any time rest all are mug heads and also depends on luck !! Those very few intelligent ppl will be working for confidential projects at MSR or something better