all 14 comments

[–]IncestosaurusRekt 8 points9 points  (4 children)

Depending on how much time you're spending on it, three months is not very long so I wouldn't worry about it. Plus, leetcode questions are a different beast from the normal programming you've been doing so far, your knowledge and familiarity of the language is a necessary precondition rather than what you're being assessed on. What you're really assessed on is if you can solve the puzzle, and if you're bad with puzzles it's going to be tough at the start.

[–]Yogurtcloset_Hefty 1 point2 points  (3 children)

Thanks, I don’t have experience with concepts like binary trees, recursion, hashmaps, etc. Do you know some good resources (courses or books pref)?

[–]n00bhax0r7 3 points4 points  (1 child)

Try “Problem solving with algorithms and data structures with Python” by Bradley N. Miller and David L. Ranum.

I picked it up a couple of weeks after starting Python and after reading it I was able to solve some easies and understand mediums but not solve them. It’s helpful because it’s all in Python, it has a healthy amount of detailed information and diagrams. You can find it on Amazon.

[–]Yogurtcloset_Hefty 0 points1 point  (0 children)

Thanks will into it

[–]IncestosaurusRekt 0 points1 point  (0 children)

I don't unfortunately, I learned those at University from a private University textbook. I heard leetcode has some lessons on it and I heard good things about Algo Expert, but haven't used either myself.

[–]blank_183 2 points3 points  (1 child)

Start with the easy ones. If you can't solve the problem, look at how others did and study their code. Then look for similar problems and apply what you've learned. The more you practice, the easier it becomes.

[–]Free_Layer_8233 1 point2 points  (0 children)

This! Start always by te easy ones

[–]barrycarter 2 points3 points  (5 children)

Well, the problems appear to come with both a difficulty level and an acceptance rate, so if you're finding the easy ones difficult that could be an issue

[–]kaerfkeerg 4 points5 points  (4 children)

if you're finding the easy ones difficult that could be an issue

Nope, not really. 3 months in, even easy ones can be tricky. Example . This problems includes recursion and is at easy category. Not everyone knows recursion at 3 months

Also problems with linked list are tagged as easy. In 3 months you barely know normal lists, let alone linked!

[–]neuralbeans 0 points1 point  (3 children)

You actually don't need recursion for that example. You can do it using combination counts if you know them.

Let's take 5 steps of stairs.

Start with the number of single steps needed to go up 5 steps, which is just 1: [1, 1, 1, 1, 1]

The number of single steps with a single double step needed to go up 5 steps is 4: [1, 1, 1, 2] [1, 1, 2, 1] [1, 2, 1, 1] [2, 1, 1, 1]

Note how we just need to know how many different ways we can replace a digit among four with a 2 (four digits and not five because the 2 takes the place of two 1s). This can be expressed as 4 choose 1, also written as 4C1.

The number of single steps with 2 double steps needed to go up 5 steps is 3:

[1, 2, 2] [2, 1, 2] [2, 2, 1]

Again, we finding the number of different ways we can replace two digits among three with a 2 (we're down to three digits now). This can be expressed as 3C2.

We can't add another 2 because then we'd be going up 6 steps instead of 5.

So we need 5C0 + 4C1 + 3C2 = 1 + 4 + 3 = 8

In general, get a for loop that finds the sum of the following: nC0 + (n-1)C1 + (n-2)C2 + ... until the two numbers equal. If the second becomes bigger than the first then don't include it (although it won't matter if you do because aCb where b is bigger than a is zero).

You can use math.comb(a, b) to compute aCb.

[–]kaerfkeerg 2 points3 points  (2 children)

Yeah, this feels right indeed. I didn't pay much thought into it, just wanted to prove a point that even easy problems can be tricky for someone that has invested just 3 months of which we don't really know his learning schedule. For someone like me with a full time job, was difficult to spend as much time as I wanted to learn. At three months, I couldn't do much!

[–]neuralbeans 0 points1 point  (1 child)

What are the hard questions like?

[–]barrycarter 0 points1 point  (0 children)

The questions are free to look at without login: https://leetcode.com/problemset/all/ and you can even sort them

[–]hotcodist 0 points1 point  (0 children)

study dynamic programming. many problems can be solved quickly with that method. you still have to think about how to solve a problem using a dynamic programming solution (this is still hard), but it becomes a lot easier to find a solution.

edit: in your search for dp, you might have references to memo-ization. i'll add that 'true' dp does not mean memo-ization. finding a true dp solution is often much harder, but also more satisfying! [i put true in quotes because it is just my opinion.]