Tech IndustryJan 8, 2020
WorkdayRHki38

How to get better at optimizing algorithmic problems?

Shockingly, I was given some very targeted (and very actionable) feedback from my Google on-site. On the ability to get to a solution quickly, I know I really just need to practice more. But I feel that learning how to optimize solutions (whether via DP or iterative [vs nested looping]) is more nuanced. What ideas do folks have on learning the ability to optimize? Is it really just practicing more LC (or equivalent) and then start to recognize optimization patterns? NB: TC is for the Rocky Mountain West region TC: ~$250k (now), in April, either ~$270k or more as I hope to be promoted YOE: 19

Add a comment
NetScout p85 Jan 8, 2020

Could you please share your feedback?

Workday RHki38 OP Jan 10, 2020

Sure, there were two facets. One was efficacy which could be read as two ways (speed to the solution or efficiency at getting to the solution [I.e., did I make a bunch of mistakes and have to backtrack). In my case, it was speed to the solution. I suspect, strongly, if I hadn't been so damn focused on getting to a solution, I would have done better. I think I took the "just get to a solution first and then optimize it" a little too much to heart. The second was finding the optimal solution to a problem. I was able to solve the problems, just not always optimally. I will say, I asked point blank for my scores and was told they don't do the 1-5 scores anymore. Rather, they do a general recommendation of no-hire -> hire (or somewhere in between). I was somewhere in between which is still a no because if you're just lukewarm on a candidate, you don't hire them. IMO, a lot of the tech firm hiring process is designed to weed out false positives, not avoid false negatives. That is, it's viewed as better to not hire a bad candidate than miss out on hiring potentially a good one.

Oracle chodraj Jan 8, 2020

What was the feedback? Also TC or GTFO. How many LC have you done? It's really just about practice and doing them more. Do spaced repetitions for questions you've already done along with new ones. Do them in a way which makes you understand the pattern and underlying concept. Also, learn, adopt from all the beautiful code and solutions by others for the same problem once you've solved it

Workday RHki38 OP Jan 10, 2020

Updated post with TC. Next time, don't be such a d**k. Clearly I didn't do enough problems - I didn't keep track but it wasn't a ton. TBH, two places where I initially got stuck in the interviews and had to work through things wasn't going to be solved by doing more LC. The last problem I wasn't able to figure out a more optimal solution - that is, it didn't immediately jump out at me. I think I have an idea for studying for the next time I go through this based on some things I found.

Amazon NYCOrBust Jan 8, 2020

Did 500 + problems. There’s really tricks to optimize these algorithms. I could probably teach someone how to come up with the optimized algorithms in a week. But I’d rather keep that information hidden.

IGT lfgbrah Jan 8, 2020

What a useful comment, thanks for the insight

Amazon NYCOrBust Jan 8, 2020

I’ll give one away for free. This is one is pretty common so it’s not a trade secret. If your constantly querying subarray sums, which costs O(n) time, you can use prefix sums which will reduce the query time to O(1). This can often reduce an algorithm run time from quadratic to linear. As exampled above, there are algorithmic techniques that can help reduce complexity in specific situations. There’s maybe 70 of these types of algorithmic techniques. Most leetcode problems can be solved using combinations of these techniques or what some people call patterns. The “hard” leetcode problems are usually problems whose techniques are either less mainstream or require multiple of the 70 ish techniques to solve. I say “hard” in quotes because it’s not hard when you know all the tricks and many mediums are impossible if you haven’t been exposed to the techniques before.