Skip to main content

Get the Reddit app

Scan this QR code to download the app now
Or check it out in the app stores
r/leetcode icon
r/leetcode icon

r/leetcode

members
online

How do you guys get good at DP?

I'm really struggling with grasping DP techniques. I tried to solve/remember the common easy-medium problems on leetcode but still get stuck on new problems, especially the state transition function part really killed me.

Just wondering if it's because I'm doing it the wrong way by missing some specific techniques or I just need to keep practicing until finishing all the DP problems on leetcode in order to get better on this?

------------------------------------------------------- updated on 26 Jan, 2023--------------------------------------------------

Wow, it's been close to a year since I first posted this, and I'm amazed by all the comments and suggestions I received from the community.

Just to share some updates from my end as my appreciation to everyone.

I landed a job in early May 2022, ≈3 months after I posted this, and I stopped grinding leetcode aggressively 2 months later, but still practice it on a casual basis.

The approach I eventually took for DP prep was(after reading through all the suggestions here):

- The DP video from Coderbyte on YouTube. This was the most helpful one for me, personally. Alvin did an amazing job on explaining the common DP problems through live coding and tons of animated illustrations. This was also suggested by a few ppl in the comments.

- Grinding leetcode using this list https://leetcode.com/discuss/study-guide/662866/DP-for-Beginners-Problems-or-Patterns-or-Sample-Solutions, thanks to Lost_Extrovert for sharing this. It was really helpful for me to build up my confidence by solving the problems on the list one after another(I didn't finish them all before I got my offer, but I learned a lot from the practice). There are some other lists which I think quite useful too:

* https://designgurus.org/course/grokking-dynamic-programming by branden947

* https://leetcode.com/discuss/general-discussion/458695/dynamic-programming-patterns by Revolutionary_Soup15

- Practice, practice, practice(as many of you suggested)

- A shout-out to kinng9679's mental modal, it's helpful for someone new to DP

Since this is not a topic about interview prep, I won't share too much about my interview exp here, but all the information I shared above really helped me land a few decent offers in 3 months.

Hope everyone all the best in 2023.


Honest Opinion: C/C++ or Python? Honest Opinion: C/C++ or Python?
Question

Most of my life I have worked on C programming language and used it in embedded programming, I love to code in it. But when I jump to Leetcode for solving things, I see C takes a lot of time, lines of code, whereas python does the job in few lines itself.

But still I think with C I am knowing what I am doing it gives me more freedom to actually see what is going in background whereas for python, boom, include some magic** and it works like a charm,

I am open to learn Python but not sure will it help me out in real world interviews, if someone asks me something, i am not a competitive programmer, I want to just learn new things and use them in my work,

any guidance should I go for python? or stick to C?

e.g. Sorting algos we need to implement in C to solve a question, max I can use is a qsort but python does the job using sort() function not sure if many python programmers know what goes in the background of sort() function, I may be wrong


System design interview coming up? Check out how we design YouTube System design interview coming up? Check out how we design YouTube

Hey all, Evan here again.

We have more System Design breakdowns for you! This time for the popular question, Design YouTube.

https://preview.redd.it/system-design-interview-coming-up-check-out-how-we-design-v0-l4oa7dd4lqcd1.png

We're now up to 14 total breakdowns for common problems. If you have a system design interview coming up, I highly recommend you give them a read through!

We also started making YouTube videos for many of these. So if videos are your thing, checkout:

You can vote for what question you want us to breakdown next by submitting your vote here. We'll do a detailed breakdown for the top voted question every couple of weeks.

If you have any questions, feel free to leave a comment here or on the posts themselves!




Microsoft Senior SWE Interview Experience (with offer) Microsoft Senior SWE Interview Experience (with offer)
Intervew Prep

Here's a detailed breakdown of my recent interview experience with Microsoft. I hope it helps anyone preparing for a similar set of interviews!

  • Microsoft Role: Senior Software Engineer (Azure)

  • Hiring Quota: 5 spots available

  • My Demographics: White // Male // Millennial // 6 Years of Experience // US Citizen

  • Current Role: Staff SWE // Large startup // Fully remote

  • Resume: https://i.ibb.co/JyckGJ7/resume.jpg

  • Microsoft Offer: Role: Senior SWE (L63) // Base: $176k // Signing Bonus: $15k // Stock: $120k over 4 years // Bonus: 0-30% // Fully remote

05/04/2024 - Applied on website (found role on LinkedIn)

05/16/2024 - Recruiter Email

Included ~20 questions. Questions were biographical/hr, background/experience, what you're looking for in your next role, and 2 role specific questions.

06/18/2024 - Technical Screen

  • Who? Principal Engineering Manager (hiring manager)

  • What? 1hr. LeetCode

  • Question? 210. Course Schedule II (domain/details were changed but problem was basically the same)

  • How'd I do? Fine. Didn't find an optimal solution. Barely found any real solution, tbh. Interviewer stepped in to help many times. I made the key insight to treat the data as a graph and I think that was required not to fail. I was very communicative and that's probably why I passed.

07/01/2024 - Onsite Prep

30 minute prep call with recruiter/scheduler.

07/02/2024 - Onsite Rounds 1 & 2

Round 1:

  • Who? Principal Engineer

  • What? 45 min. LeetCode, 15 min system design.

  • Question? 295. Find Median from Data Stream. Interviewer also expected it to be implemented in an object oriented manor.

  • How'd I do? I think I failed this one tbh and it got me down-leveled from 64 -> 63. I gave a solution involving binary search/inserts over a sorted list. Correct answer is min/max heap. It's a commonly known problem and I think the interviewer basically expected me to know it. Positive feedback was that I communicated well and structured the interface well, even if implementation was suboptimal.

Round 2:

  • Who? Senior Engineer

  • What? 1hr. LeetCode

  • Question? 146. LRU Cache

  • How'd I do? Perfect. I coincidentally did this one the day before, and I believe I had more experience than the interviewer.

07/03/2024 - Onsite Rounds 3 & 4

Round 3:

  • Who? Senior Engineer

  • What? 30 min. LeetCode, 30 min system design.

  • Question? Basically create a class that lets you add/remove nodes from a tree. Started with coding, then asked to convert to distributed system.

  • How'd I do? Very positive feedback on the coding problem (super simple problem, but I think my communication went a long way). Fine feedback on the system design. Basically just had a client, load balancer, service, and database lol.

Round 4:

  • Who? Principal Engineering Manager (different from tech screen)

  • What? 15 min. technical/background discussion, 45. min system design.

  • Question? Pretty challenging question about creating a aggregating all data for all tenants in Azure. The hard part is not making too many requests to any tenant/subscription at once (or else you'll rate limit the customer).

  • How'd I do? Okay. Was caught off guard since the recruiter told me this round would be all experience/culture. The solution is to query each tenant and add their subscriptions to a queue, then for each subscription in the queue add all their resources to another queue, then for each of those get the data. I tried some sort of Apache Spark scheduling thing to balance between tenants the interviewer didn't like. The interviewer told me the correct answer is to re-enqueue a job every time you hit a rate limit (with some jitter to prevent bunching). I didn't finish in time, but the interviewer gave me an extra hour to finish the whiteboard design and snapshotted it after.

07/08/2024 - Initial Offer

Negotiations ongoing.

07/15/2024 - Final Offer

Offered $194k base, and I declined the offer.

LC Stats

From Jan 2024 when I started practicing until the day of the first onsite.

  • 2.2 problems per day

  • 31 active days

  • 68 solved problems

  • 24 easy (35%)

  • 44 medium (65%)

  • 0 hard (0%)

  • 80 attempts

  • 12 retries

  • 57.51% avg runtime

  • 47.19% avg memory

  • 0:30:20 avg problem

  • 1:15:50 avg day

  • 40:26:48 total time

My Top Resources



The interview finished earlier. Is it good? The interview finished earlier. Is it good?
Intervew Prep

I had an interview with a big local IT company today. After a brief introduction, I was given a problem to be solved. The problem required me to return squared values of elements in a sorted array in the sorted order. During the interview, I discussed some ineffective solutions using sorting, heap, and two arrays. Finally, I proposed a linear time solution using two pointers and implemented it in Python. I finished the solution (with working code) ~ 30 min after the beginning of the interview (including the introduction of myself and the problem), and the interviewer said something like "It is everything clear to me, we can finish the interview at this moment". He asked if I had any questions about the company/position/etc. I have asked a few. But now I am full of doubts. The interview should go for 60 min. Usually, they ask to solve 2 problems but I was asked to solve only one.... Based on your experience, is it a good or bad sign?








DSA in Python resources DSA in Python resources

I am an upcoming sophomore and I wanted to explore DSA in Python and was looking for resources for the same. I don't mind buying some course if it is good. I completed C programming from college Wallah youtube channel and was thinking of buying it's DSA with python course. If any one has taken that course I would love to hear the reviews regarding the same and other resources for DSA in python are appreciated.

Thanks in advance :)


How do LC contests even work? How do LC contests even work?
Question

I've been familiarising myself with LeetCode contests and I haven't actually participated in any because they don't really fit my schedule.

I have so many questions to ask as there is not much info on LC about them.

First of all, is LeetCode literally just not doing anything about contest cheaters? I open up a contest discussion to see thousands of people ranting on about top 10 LeetGPT cheaters. Does LeetCode not even take this seriously? You get 5000 LeetCoins and a free backpack for achieving first place, like come on! Where is the regulation here?

Second of all, does the contests take place at strictly 8am or 8pm depending on whether it's the biweekly or the weekly? So there's no way to make it flexible for your schedule?

And finally, are all the problems from the contest new? Like I notice that all the problems are just the very last LeetCode problems, from like 32XX or something like that. Does this mean that every contest 4 new problems are added to the ever-growing library? So it is impossible for anyone to have done the problems before the contest?

I am so confused...







Thinking of giving up LC grinding. Thinking of giving up LC grinding.

Hi All,

I have been grinding LC for more than 100 days now. I have coded all the problems in GRIND-75 and 111/150 from Neetcode, mostly by watching some video. I never copy the code but implement the explanation myself. But when i see a new problem or even the problems i have solved few weeks back, i get anxious that i won't be able to solve. However, I can correctly guess what DS/approach will be used but cannot solve the problem within 20-30 minutes sometimes even after 1 hour. It makes me sad and irritated. I don't want to give up but it is hard to keep myself motivated. Most of the days i feel sad because i couldn't solve that one problem.

I am thinking to attend contests or daily challenge but i am scared that i will fail miserably. Please help me guys.

I have a 9-5 job and a family with children.

Edit - I must admit that sometimes, i just keep writing code half-heartedly and submitting on LC. I think, i should not start writing code until i have written psuedo code on paper and dry run with few test cases.

Thanks.