Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Did you just start off doing leetcode questions online and learned from the solutions? I'd study leetcode stuff if I could even start getting interviews to show my skills :/


Yes, and I went against the standard advice to not look at the solution until you solve it yourself. I think for the first 50-100 problems it's best to not think too hard about it before looking at the solution, gaining a full understanding, and writing an implementation or three (building that muscle memory so to speak).

At this point, you'll have many more tools in your kit (graph traversal, search, dynamic programming, queues, heaps, stacks, etc.) and you can work on coming up with your own solutions to new problems. But I found it to be a waste of time staring at a problem for hours when I didn't already have the fundamentals in place to tackle it.

The other thing I did was watch youtube videos to get a better grounding in some of the data structures that I struggled with. I mostly did this wish graphs, as I was always terrible at graph problems and never had to apply them in my career. I found this series of videos to be extremely good.

https://www.youtube.com/playlist?list=PLDV1Zeh2NRsDGO4--qE8y...


Excellent practical advice.

That part of just following the solution for the first 50-100 problems is spot on. It resonates very well with my experience learning math by first following the "solved" examples, fully understanding them, then solving similar "simple" problems, repeating them till they fit into muscle memory and only then attempting the challenging ones.

First challenge I faced with leetcode is they do not have a concept or technique map. Similar to the chapter index in any math textbook, each dealing with a specific technique, concept or pattern. For example the idea of using a hash to store a running sum is useful for a class of problems like finding the longest sequence that adds to a specified sum, longest sequence of equal no of 0s and 1s. Yet, there was and still isn't a page or resource where such a pattern was described.

Solving leetcode feels like swimming upstream, one problem at a time, looking for patterns. Some are well described (Kadane for example) but most aren't. I looked around the web but couldn't find any resources that helped me with this.

I wonder if we could, at your experience, list some concepts and techniques that can be repeatedly useful. I believe that could cut the prep time by a good degree.

Second related problem to this is retention. With this master technique map, it would become easier to review and revise quickly. (I tried spaced rep, not useful) The most effective strategy for me has been to put everything in one book.I have multiple index pages with lists of similar problems pointing the page numbers with the solution.

I have been able to get better at data structures using this approach now I'm at the leetcode phase.

Appreciate your response.


I completely agree about leetcode lacking a technique map/graph/tree. This would be immensely useful. In my studies I found that I naturally gravitated to classes of problems I was already good at, because that way I could avoid the mental pain of learning new techniques. I really needed a roadmap that lead me to what I actually needed to study, and that showed me where I was strong and weak. But as you said, they never make it super clear which techniques a problem uses, and how those techniques build on and relate to other techniques.

I'm really glad you bring it up, because I had actually been pondering ideas for making a better programming training site based on the idea of a skill graphs (similar to an RPG), repetition to build muscle memory, clear progress tracks based on the graph of skills, and greater insight into your strengths/weakness/progress with metrics.

As far as enumerating techniques, I'd need a good deal of time to work on that. I think there are two classes, the macro, being data structures/algorithms and what type of problems they apply. And the micro, which is more implementation specific techniques. Things like using a loop with two pointers into the same structure (ie: find a cycle in a linked list).


Well thanks for your comments. Feels assuring knowing I'm not alone (although clearly in the minority) waving my hands at how crude and ineffective the common advice to "do leetcode" really is. That training site idea sounds exciting, much better than what exists today.

The key perspective shift from me was from - "I need to solve 200 leetcode problems before I can approach interviews with confidence" to - "Here are 50 techniques. Most solutions use a combination of these"

I started my journey splitting things into buckets (Arrays, Strings, Binary tree, BST, Stacks, Linked List, Matrix, Graphs, DP). I went through EPI and Leetcode populating those buckets. I started solving the easies for a month. Built a repo of questions and links so huge, it would take me years (really, years) to get through it sequentially. That was depressing and with no sense of immediate reward, gave up.

A few weeks later, I decided to reduce scope and focus only on Arrays, Strings, BST and Graphs. Turns out that isn't a great approach either as there are a lot of overlaps between Array and String problems and by the time I got to the string problem that used a technique similar to what I had used in a problem in Arrays, i'd forgotten most of it anyway. Repeated this a few time and it gave me the impression that I couldn't remember shit, I wasn't cut out for this and gave up, again.

My latest attempt is to focus on data structures (properties, strengths and tradeoffs) and techniques. This has been liberating so far but is a lot of work which drove me to look for resources adopting such a perspective and I found none. I believe its probably a lot of work (like you mention) but I wouldn't know unless I get through more problems. ¯\_(ツ)_/¯


Yeah, it's really easy to get overwhelmed by the raw amount of stuff to study. I found I just needed to be consistent, and get through 3-5 leetcode problems a day, while trying to force myself to hit the problems in areas I was weaker. If I tried to enumerate everything, I quickly became very overwhelmed like you describe.

I think if you hit a balance of problems that touch on arrays, strings, linked lists, trees, graphs, stacks, queues, heaps, and also some dynamic programming you'll be good to go. I found that companies really love to ask graph problems in disguise, and once you know how to recognize them and the basic DFS/BFS implementations you're golden. And if you get good at graph problems, trees and linked lists are simple, so I think it's a great area to put extra focus.

I found the dynamic programming problems particularly hard for my brain to grasp, and I had to spend a lot of time repeating the basic problems and slowly building up my skillset. A ton of practice, and I never even got asked a single DP question in all the interviews!


Thanks that's solid advice.

I imagine that strategy ( focus on weaker areas and be consistent) to work more reliably than making it a numbers game.

Appreciate your comments and hope you can see that training website through to a real product. Would benefit a lot of people like me.


Thanks solid advice I can related as I did follow the same after wasting lot of time on LC problems I cant solve. I have started getting good at LC. Since you landed job at FAANG, I would really appreciate if you can share tips on specific question says finding max path in a matrix it is graph problem but how can you master it so code flows in 30 minutes or less. Did you actually solve same problems multiple times?


If you want the code to flow easy, it's all about putting in the hours and working at the right level of difficultly. Not too hard, so that you're not making any progress, and not too easy such that it's not stimulating your mind. Think of it like hitting the gym, it's just you're building mental muscle (and stamina) instead of physical.

And yes, many problems I solved 3 or more times. If you go to the discussion section, you'll see a number of different popular solutions by users. Try to understand and implement a few of them to get a greater understanding of the problem. Once you feel like you know the problem well, delete all your code, see if you can re-implement it in under 10 minutes, then try again for 5. Keep putting in those reps, you'll get faster.

Think about how fast you can write out a simple for loop. You probably don't even think about it, the code just "flows" out. That's because you've done it hundreds or thousands of times, your subconscious takes over. You can get to that point with more complex things like breadth first search, depth first search, dynamic programming, path finding, etc. you just need to get the reps in. It's a lot of work, but if you put in the time (try for a couple hours a day) you will see the results. And, once you start getting better, leetcode can become addictive like a game, which makes practice much easier.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: