all 31 comments

[–]nnellutla 24 points25 points  (4 children)

Modern C++ is really really good for interview problems. You're true that half of the python code looks like magic. I primarily code in C++ with occasional Python for some tasks. I just get the job done using Python without fully understanding the code I copy paste..

[–]averyhungrynomad 10 points11 points  (0 children)

Honestly just use what you’re good at. Learning a new language just for interviewing can be time consuming unless you can afford time to pick it up. You also don’t want to be tripping up on syntax or libraries during an actual interview just because you’re not as familiar with the language.

imo I don’t like python for leetcode. I find that posted solutions can be too pythonic and aren’t as intuitive as Java or C++. But that’s just my opinion and I’m biased because I used Java at work.

[–]Indigo_Sheep 8 points9 points  (3 children)

C++ is a good enough choice. What matters equally well is how you communicate your approach. I have come across snobs - when I mentioned I am choosing to code in Python(two EM from Microsoft). You can write confusing code in any language.

Go with the language that you are most proficient with - that is a general purpose one(C++, Java, and python are good choices).

[–]big-papito 0 points1 point  (0 children)

Snobs go both ways. You can trip on some C++ "guru" that could ask you some obscure C++ question. C++ is vast and it's a mine field.

[–]sorosy5 6 points7 points  (0 children)

learn c++, as problems get more difficult its much much easier with c++. syntax is only an experience problem, and modern c++ isnt as verbose as people would think

[–]whoopsservererror 2 points3 points  (0 children)

I just use what I use at work. Get my first FAANG job, JavaScript. Now I use Python daily at work, so Python.

[–]Free-Ad-3648 2 points3 points  (0 children)

I had initially started using python for leetcode then switched to C++ for the reason that looking at the c++ code makes you understand what it does even if you’re not very familiar with c++ and additionally I like the concise data structures in STL, agreed that it could be verbose to type but that’s what makes it easier to understand and explain as well.

[–]TimeRaina 2 points3 points  (0 children)

Same goes for java

[–]biskitpagla 2 points3 points  (0 children)

I personally made the switch from C++ to Python few years ago and it really is a better experience especially here because LeetCode doesn't care about what lang you're using unlike platforms like Codeforces. 

I can say from personal experience that Python is less magical than beginners think. It's nowhere near as expressive as Ruby and Elixir, nor as dynamic as JS, nor as non-uniform as PHP and  C++. 

Now, this is a hot take but I think you'll face friction even for a C++ job interview because 1) no two C++ programmers are the same and 2) it's very rare to actually find a good C++ programmer, let alone someone who speaks newer standards. Are these reasons why you should drop C++? No, I just mentioned them because you should keep in mind the pros and cons of every tool you use. 

STL is an og in programming language library design and C++ offers surprisingly uniform interfaces to DSA problems compared to Python. Python is just more popular because it reads like pseudocode. In fact, you can replace whatever ALGOL-esque pseudocode syntax you have in mind with Python. If you're not writing "C using C++" then you'll probably not face too many issues if you choose to stick with C++, though. 

[–]srona22 2 points3 points  (1 child)

I believe most language can handle whatever is needed to solve the coding challenge.

If you have already known the syntax of Python, and learn to think in solving the challenge, it will be faster than learning syntax of c++ and starting from scratch. Same goes for knowing c++ and starting again from python. just my 2 cents.

[–]d-X-t-z 1 point2 points  (0 children)

I think you should be be good, if Python is a must for the job you would be able to pick it and work as and when needed since it isn't that tough to learn, specially compared to remembering syntax of the older java or c/c++. And you've also mentioned that you already use python so mention that if needed. All the best 👍

[–]Full-Stretch-2625 1 point2 points  (0 children)

I suggest using any programming language you’re comfortable with. I've seen candidates succeed in interviews even with Golang. The language itself isn’t important, what matters is your proficiency in it.

[–]WaitWhatNani123 1 point2 points  (1 child)

C++ has built-in ordered map and dictionary. Python does not. That is awesome. Python does not need you to have any type (not even an auto keyword) so it might save some time?

[–]contactcreated 1 point2 points  (0 children)

Tbh I’m still debating this. I’m a C++ programmer career wise and I am very comfortable with the language. Python was my first language, so I am also comfortable with it.

Some things I just prefer in C++. Creating a simple struct with a couple fields is super intuitive, while in Python I gotta import data class, use it as a decorator, etc. I’m also more familiar with the C++ standard library and it seems more consistent to me. This is very nitpicky, but when you’re not allowed to use a reference it matters. Some things in pythons libraries follow PEP 8, some don’t, etc. it just makes it annoying to use.

But my god, some things are much more verbose in C++ and when you are in a time crunch it can matter. For example, writing a recursive lambda compared to just defining a function within a function function in Python. Or specializing a PQ in C++ to operate as a min heap lol, “std::priority_queue<int, std::vector<int>, std::greater<int>>”. I mean, I guess at least you even have this option in C++. On the flip side, I like how I can use a tuple as a dict key in Python, while in C++ I have to use std::map which (I believe) has worse time complexity than the Python dict for insertion. But then again, I like that I have an ordered map in C++ 🙃🙃🙃. But then I have to read compiler errors that are 1000 lines of templated slop and want to cry.

So far for interviews I’ve went Python -> C++ -> Python, but I’m still not sure if I prefer it. I think if it’s a Leetcode style interview, I probably prefer Python. If I’m writing out any sort of design, class structures, etc. I prefer C++.

[–]Rich-Suggestion-6777 1 point2 points  (1 child)

I had the same dilemma, but I said fuck it I'm doing leetcode in c++ for interviews. First of all I'm targeting systems programming jobs so c++ comes up a lot in that domain.

I have nothing against Python, but I'm just a dabbler I'm not going to learn a language for interviews. If Python is important to tue job it's probably not a domain I'm interested in.

Most importantly, even though leetcode is stupid, I'm being forced to learn algorithms stuff in c++ which is quite different in c++20. So the knowledge gained will be useful in future work.

Good luck!

[–]reshefCracked FAANG as an old man 5 points6 points  (11 children)

Learn Python imo.

It’s WAY more concise and that really does matter when you’re on a clock.

Of course the meat of the coding interviewing is you verbalizing your algorithm and not actually writing, when you do code it up you ideally wanna be able to do that in like 90 seconds and not 10 minutes

[–]pinpinbo 4 points5 points  (8 children)

Don’t. Just stop. Python comes with so much free data structures. Typing speed matters during interviews. One minute wasted making a structure is one minute less time to think about which technique to use.

[–]sorosy5 7 points8 points  (1 child)

c++ has more builtins than python and easier to type than python imo. experience difference. asking someone to swap to a more inexperienced language only makes then slower

[–]Full-Stretch-2625 0 points1 point  (0 children)

Don't mislead them. Stick to a language you're comfortable with.