Am I just too stupid for Leetcode?

General Rules

  • This Forum Rules:
    1. No asking for course requests or download links.
    2. Don't share links to other websites for downloads or references.
    3. Avoid controversial topics in discussions.

    4. Use an appropriate thread title that matches your content, not just a word.

    Other Forum Rules Can Be Found Here

flamingass

Well-known member
TutFlixer
Jan 13, 2021
221
4,793
52
localghost
Lately after my day job I have been preparing for interviews(scheduled 45 days now) a. Completed a basic DSA course in a week. So now I have been spending time 3-4 hours after work on preparing for Leetcode interview questions and System Design.

My God do I feel stupid not being able to solve even the 'Easy' questions! Often I get stuck for 20 minutes or so and then end up looking at solutions.

For background -> I have been working for a little over 2 years in SAAS backend. Decent at my job. While I know that acing Leetcode is not a true representative of your developer capabilities, it is unfortunately a required skill if you have to crack high paying development jobs(especially in Product based companies).

I have a few questions for those who are good at solving Leetcode questions or have been practicing there for a while and have now developed intuition. Felt this might also be useful for other folks who are in Leetcode grind.
  • Is there a list of MUST-DO and ALMOST-BY-HEART questions I should target first?
  • Any kind of notes that people have compiled after solving questions. Like notes with patterns/techniques noticed that can be used on multiple questions with minor tweaks?
  • Any other suggestions/tips/pointers that should ideally be addressed in my attack plan for next ~40 days? I'll try to strategize based on your recommendations.
 

imml97

New member
TutFlixer
Sep 22, 2020
16
23
3
India
Hi,
Well, there are different things that work out for different people. For me what worked out is whenever I solved a question, I basically noted the name of the question, what I learned from it, and in what pattern does this question belong. With this, I was able to solve 510 Leetcode questions. Lately, I basically changed my approach and started maintaining different lists that I use as indexing to refer to questions that have some pattern between them.

Yes, there's a pattern in every question. Yes, it isn't easy to find one.

You can consider this an example, I have like 30-40 such lists.
Please, Log in or Register to view URLs content!


If you have 30-50 days as you say, try to finish the most common interview questions and try to extract what is common between them. Interview bit has a very famous and pretty accurate list of the 300 Most famous interview questions.
Please, Log in or Register to view URLs content!
 

frosty

Member
TutFlixer
Scripting...
Nov 24, 2020
100
38
19
UAE
For me, I was in the same frustrating position for the first 2 months. After that I started to see some recurring patterns in the questions. They key here to note is that all questions follow some sort of pattern and once you are experienced with a particular pattern, eg: 2 pointers, then all questions falling in that category becomes easier.
 

RahulV36

New member
TutFlixer
Dec 17, 2020
20
16
3
India
Hello , I had prepared for DSA and coding tests in my college final year. I didn't do leetcode at that time. I just used GeeksForGeeks and by hearted the list of their most asked questions
Please, Log in or Register to view URLs content!
. In this list also , I didn't do all the data structures , just the most common ones.
The interviewBit list shared by imml97 looks great too.
I think a lot of companies just repeat these questions or they directly pick their questions from these websites. So its a good strategy to by heart them even though its not the most honest way.

And you are not stupid. It just takes time, practice and a lot of patience to develop the ability to solve coding problems.
 
  • Like
Reactions: flamingass

flamingass

Well-known member
TutFlixer
Jan 13, 2021
221
4,793
52
localghost
Way to go! 510 questions is no joke. Big up to your resilience. Appreciate you sharing those links & insights too.

I got the meat of your idea to consolidate similar questions & index them as you go. Found the LInkedlist gist pretty handy. If it isn't too much hassle, do you mind sharing all your lists & index? Certainly would be a big help. Can DM you regarding the same.
 

true21mannu

New member
TutFlixer
Mar 20, 2021
2
11
3
India
Bro,
There can be a zillion reasons why we cannot find a way to solve a problem on leetcode? but for me below are the reasons I am not able to solve.
1)There is some sneaky data structure that I don't know ever existed.
2) an algorithm I don't know.
3) An interesting or fancy way to use an algorithm or a data structure.
4) I knew the data structure or algorithm but wasn't able to come up with the reasons to "Why exactly I should apply the data structure or algorithm".
5)Had a brute-force solution but have no idea to optimize it further.
For the first 3, you have to solve problems topic by topic first to get a good understanding of how these algorithms and data structures work. I recommend you to follow Data structures and algorithms by Narasimha Karumanchi. It will brush up on your existing knowledge. However, just don't jump to the solution spend at least 10 minutes on every problem.
For the last 2, I have created a Step by Step method to follow so that you never miss what you have learned and apply everything you know still in few minutes. You might have to dedicate more time upfront but as you follow the technique more and more you will significantly apply this.
I call it the UEBOWEWCT Technique: Each letter in the capital is a step of this technique.


  • Understand:
    • Understand think what might be the cases ask doubts to yourself regarding it.
  • Example:
    • Take not very big(medium-sized) example Which is generic and does not contain Special cases or edge cases.
  • Bruteforce solution:
    • this is the most basic solution to the problem. This is not most efficient but still coming up with this will give you some progress towards the actual solution.
  • Optimize
    • use UIBADS to optimize the brute force algorithm you have.
      • Unnecessary
        • some kind of extra work you are doing that is not actually required to do or some intelligent way to reject some part which will reduce time complexity.-
      • Info consideration:
        • Every bit of information given in the problem or interview is given because it has to be used in some way to come up with the solution. So if there is some information that is not used then try to come up with a way to use that information to improve time complexity.
      • Break the problem into parts
        • Sometimes bigger problems are very complex to optimize so just divide the problem into small bits and pieces. So that you can solve these simpler indivisible problems separately and then club them up to which might cut time complexity by a significant amount.
      • Apply All data structures:
        • At first, Think of possible DS which is in some way relevant to the given problem or might be related to the problem of a similar type you have done in the past and try to apply these data structures to it.
        • If the previous point doesn't help then randomly apply all the data structures you know one by one to the given problem.
      • Duplicate work:
        • There might be the case where you are doing the same computations more than once and this redundancy might just cost you extra time. So in this case you compute it once and store it, And whenever you need it again you can get it from memory which saves a significant amount of time.
        • This case generally comes up in the case of recursion.
      • Simplify:
        • Some times when the question given to us is so complicated then in such cases we can just simplify the problem by reducing come conditions or ignoring some conditions and solving it and later just adding them back to the conditions set.
  • Walkthrough
    • run your algorithm on small examples so that you are completely sure that
  • Edge cases:
    • Before moving further to pseudocode just think of the edge cases which will fail you from passing all the test cases.
  • Write pseudocode:
    • write pseudocode plain English like bullet points.
    • Select words which are similar
  • Sketching:
    • When you're done with the algorithm, take a couple of minutes to devise/sketch your code may divide some parts into different functions.(this point is applicable when you want to reuse a certain part of code or just make it more readable when it is very long)
    • Select functions and variable names that kind of represents the work that function does.(use camel case or underscores whichever you like to use)
  • Code The problem:
    • Write code that is clean and put appropriate indents and spaces which makes code more readable.
    • While writing code your focus should be only on converting pseudo code from plain English to the Programming language of your choice.
  • Testing:
    • take a small example and run it on your code, not on your example
    • Don't panic when you have found a bug, think about what causes that bug.

The key here is to stick to the order in which they are mentioned. You can get the best results if you stick to it.
you can hit me up at [email protected] if you have any more queries regarding it.
 

flamingass

Well-known member
TutFlixer
Jan 13, 2021
221
4,793
52
localghost
Honestly, I did not expect such a well thought-out elaborate answer! It deserves a blog post of its own. Looks like you have the system down to the T.

Really grateful for sharing this step by step insight!!
 
  • Like
Reactions: GulPanag

Student

Premium User
Premium
TutFlixer
Sep 8, 2020
12
1,063
41
South America
How familiar are you with the common data structures?
- Graphs / Trees, Arrays, Stacks, Hash Maps, Linked Lists, Queues, Heaps, Strings

How familiar are you with the common algorithms?
- Graph traversal (BFS/ DFS), Greedy, Recursion, Binary Search, Sorting?

I think the hardest part is trying to map a problem into an underlying pattern that you could potentially recognize and that comes with practice.
It ultimately comes from identifying and breaking down the problem into characteristics and thinking about what algorithms apply given certain inputs. Data structures is just a way to organize information efficiently depending on what you need to output given an input. You need to use the characteristics of a problem to your advantage as they can further optimize your solution. For example, if there are unique elements, if an array is sorted, you can use that to optimize a solution that would not be possible given non-distinct elements or an unsorted array.

The key steps to solving a problem:
1. Combine sufficient number of problem's characteristics and match to a known data structure or algorithm.
2. Generate few examples and walk through it by hand to get the patterns generated
3. Look at every substep of the algorithm. Can you optimize?
3a. Go from a higher to lower complexity and realize the time complexities for certain actions (Brute force is usually a higher complexity, but can you use the characteristics to go down?)

Tips for Solving
Don't code before planning!!!!!
1. understand the question, ask for clarifications such as input, address edge cases
2. do a toy example and work through how to solve it and what algorithm / approach to use / logic
3. think about edge cases and adjust your pseudocode
4. code solution once everything looks good

Also, realize that it all comes down to practice. There are going to be a lot of problems that you can't solve, but the best way to learn a problem is try your hardest and attempt to do it before looking at a solution. Spend time trying the problem, then look at the solution. Either look at how people go about it before looking at the code and trying to implement it yourself, or look at the solution, try to understand what's going on, and come back to it another day and try again.

Best of luck and hit me up if you have any questions!!!
 

flamingass

Well-known member
TutFlixer
Jan 13, 2021
221
4,793
52
localghost
Thanks so much for sharing these awesome tips so generously. Appreciate it!

I have read & implemented those basic data structures once. As far as algorithms are concerned, I've covered basics of recursion, Binary search and sorting -> will be solving problems pertaining to these next.
 
  • Like
Reactions: ssss8686

kogou_yzyz

New member
TutFlixer
Oct 8, 2020
22
11
3
United States
The pattern is really important, what I suggest is to use some help site like algoexpert or educative. I believe both sites have a good conclusion for the normal pattern. Finally, it is a good investment to spend money on these really useful sites. Remember, once you enter into a big tech company. You will get more than the money you spent currently.
 
  • Like
Reactions: Father Sham

Haseeb45

DEEP CODER
TutFlixer
Apr 10, 2021
13
4
3
Pakistan
I totally agree with the patterns method. Once you go through different kind of questions, you get better at recognizing those patterns. After practice, you would be able to stop thinking about the solution. You would just decide what solution would be better if applied to current problem. Also thank you so much guys for your feed back and especially the one asking the question. PEACE <3
 

rishu2022

Invest if you can afford it. Always.😎
TutFlixer
Oct 6, 2020
354
14,279
52
Google
The pattern is really important, what I suggest is to use some help site like algoexpert or educative. I believe both sites have a good conclusion for the normal pattern. Finally, it is a good investment to spend money on these really useful sites. Remember, once you enter into a big tech company. You will get more than the money you spent currently.

Adding 1 more free resource for getting familiar with patterns.
Please, Log in or Register to view URLs content!

Btw, I'm going for Leetcode Premium by the end of this year.

One recommendation was to spend not more 15-20 minutes on a problem and then watching the solutions. Just doing this consistently for 2 months (10 problems/day) maes one very familiar with the patterns.
 

Haseeb45

DEEP CODER
TutFlixer
Apr 10, 2021
13
4
3
Pakistan
Adding 1 more free resource for getting familiar with patterns.


Btw, I'm going for Leetcode Premium by the end of this year.

One recommendation was to spend not more 15-20 minutes on a problem and then watching the solutions. Just doing this consistently for 2 months (10 problems/day) maes one very familiar with the patterns.
Thankyou so much. Really appreciate the resource
 
  • Like
Reactions: rishu2022

Latest resources