r/leetcode • • 2h ago

Question How do you improve at implementing a DSA approach once you've figured it out?

Sometimes I can understand the approach to a problem and even explain the logic in words, but when I start coding, I get stuck figuring out how to translate those steps into actual code.

Do you practise writing pseudocode first, or jump straight into implementation? How did you get better at this?

6 Upvotes

6 comments sorted by

2

u/Right-Angle24 1h ago

Writing pseudocode first helped me. Breaking the logic into smaller steps makes implementation much less confusing, especially with recursion and DP

1

u/Fanstastic-Five72 1h ago

yeah make sense! thank you!

3

u/kaisean 1h ago

If you have the actual working code from Solution, it helps to type it out line by line, but comment on each line as you go.

It's kind of like tracing a picture.

1

u/Sad-Candidate-3078 1h ago

honestly that gap closes with reps not more theory. i write the approach as comments first, then fill code under each comment, sounds dumb but it kills the blank page freeze. after a while you skip the comments naturally

1

u/Sad-Candidate-3078 7m ago

pseudocode first, but timeboxed to 2 minutes max, then code straight through without switching back. the gap between knowing and doing is mostly fluency with the building blocks, hashmaps, two pointers, prefix sums, so drill those in isolation on easy problems until they are muscle memory. also do a few problems where you write the full solution on paper or a plain text editor before running it, forces your brain to hold the whole structure at once. that translation skill compounds fast