u/AlternativeCorrect55

From Cpp to Python

Did anyone make the migration from cpp to python for leetcoding?

I have been leetcoding / solving algorithm problems from during my university lives, and I am pretty decent at it, and in particular, know quite a lot of nuances and internals of the STL and algorithmic aspect of the language. I personally love how powerful Cpp STLs are (set, map, lower_bound, upper_bound) and how convenient they are for a wide range of problems. However, I feel the language is naturally slow to prototype in a stressful interview setting. Even more with problems that is not algorithmically challenging, and/or requires string handling. I felt I had underperformed on an recent interview particularly because of this and the feedback I got was: “the interviewee figured out an intelligent Trie based solution, but was not fast enough to code it up.”

Considering this, I have decided to give python a try for leetcoding, and solved around 40 problems so far of the neetcode 150 problems (I do have professional experience in python and only new to it for algorithmic problems). My experience so far:

  1. (Positive) how concise my code is for quite a few problems compared to cpp! Specially, I don’t have to worry about static types to extract out a small helper.

  2. (Negative) strings are immutable, so can’t concatenate trivially, heap api is horrible compared to cpp!

  3. (Negative) lack of set and map (ordered).

Now, I am torn between these two options. I know I might be overthinking, but I would love to here if someone has gone through a similar transition, and whether it helped or wasn’t worthwhile in your experience.

reddit.com
u/AlternativeCorrect55 — 15 hours ago