4 ms·
My coding style completely changed after solving about 400 mostly medium level LC problems LC was obviously to prep for interviews which are time boxed. This m
by jameson 5y ago
My coding style completely changed after solving about 400 mostly medium level LC problems
LC was obviously to prep for interviews which are time boxed. This means for each problem I had to:
- plan, come up with a pesudo-code and verify the correctness *before* implementing it
- write concise and readable code
- make practical tradeoffs
LC isn't fun. Maybe it is for some folks but it was discouraging for me to some extent since it made me compare with folks who can solve these problems when I'm clueless
But this was the eye-opener at the same time. It was shocking to see someone can solve the same problem with less than 10 lines of code when my code is 100+. It taught me what parts of my code was unnecessary and also some neat tricks certain languages provide
This isn't to say I'm LC God. I still suck at LC but what I appreciate is I get better little by little. I tried a medium level question last night after more than a year of break and couldn't solve it haha
I see your point about creativity. I think algorithms are mostly memorization. I'll never be able to come up with KMP algorithm or gift wrapping algorithm from scratch. However, how to apply these algos on a problem or transforming a problem into another problem that can be solved easily is creativity IMO
I do have ADHD as well and my advice is this is something you have to solve with pychaistrists with different meds and therapies.
LC is not fun but necessary to be a good engineer IMO
- agumonkey 5y agoThe 100s vs 10s loc is something very interesting. I witnessed that when doing DP or highly recursive problems (outside of LC bit still). It did alter my coding too.