#but yeah if you're thinking about using C++ for competitive programming my advice is know the standard library
Explore tagged Tumblr posts
Note
as someone who basically exclusively interviews in c++... (as in: i once got an interview, got told it was for python on the interview.... then asked "can I do this in C++?")
its actually pretty nice! all of the caveats of using c++ in production (mostly) arent there if you're doing something completely self-contained, since you get to use all of C++11 (or even better, C++20)'s features, turning it basically into something like rust - just never touch new and delete and only use the STL and <memory> and you're good to go
also, python's "hashmap as default" realllly makes programming feel weird and the lack of typechecking in alot of places leads to (i find) programming where its easy to fuck up - the C++ compiler catches alot of what would be runtime errors in python
and of course, the C++ standard library has not just the kitchen sink but also the cutlery drawers, a wok or two for good measure and half a pantry of ingredients.
want quickselect? that's std::nth_element, want to use prefix sums? std::partial_sum. want to do permutations? well by god do we have the function for you (std::next_permutation)
every data structure i've wanted was implemented straight in C++ (with the one exception of a segtree, but i havent ever actually needed to use one) even (for some forsaken reason) a doubly-linked list, which I have actually used in a solution (you can insert at the end, then save the pointer to the element to remove it in O(1) time) without having to like actually code any of these damn things
so keep your head up! i complain about C++ but it isnt that bad - especially anything after 2011
hey congrats on reaching CM (? wanted to find the post where you mention that to confirm but tumblr search misbehaves). was curious as to how many problems you've solved on cf? I primarily picked it up cause ik it helped friends with interview stuff but I'm 2 months in stuck at ~1200 so wondering if I should be doing things differently. on one hand most problems <1400 are greedy or math so I worry an actual interview will be more "algorithmic" and I'll be unprepared (maybe leetcode is better in this regard?). on the other hand it's soo much easier to fantasise about being good at cp than actually practicing. so. anyway wondering if you had any advice on this? CM in one year does not sound like the journey of your average cf-er. congrats again. cheers!
Thank you!
(full disclosure: I've kind of fallen off with competitive programming - I haven't competed on codechef since January and codeforces/leetcode since April)
My solving totals, ratings, and number of contests are:
Leetcode: 824 problems, 2571 rating, 41 contests
Codeforces: 69 problems, 2000 rating, 14 contests
Codechef: 32 problems, 2046 rating, 4 contests
If you're looking for interview prep I would skip codeforces. Leetcode problems are closer to what you'll get in interviews, and their contests are much less of a time commitment. I also code in Rust on CF/CC and Python on Leetcode, and I much prefer to take interviews in Python.
If you snoop around a bit on reddit and the leetcode forums, you can often find lists of problems people have seen at a specific company's interviews to get a flavor of what you're up against. I really recommend this - the problem I struggled with the most in getting my current job was on one such list for my company and I wish I'd gone through the list. This was before I got really good, though.
I think my rapid growth was fueled by three things:
I did math competitions all the way through college that have a similar skillset
My college classes taught a lot of competitive programming concepts (I learned what a SegTree was in class!)
I had a period of 5 months between graduating and starting my job where I was unemployed and highly motivated, and I did a ton of grinding during that period. Most of my leetcode solves are from that time
If you're looking to improve but don't have a ton of time to burn, here's the regimen I recommended to another asker:
#competitive coding#i did not get the python job btw#but i did pass that interview#also for the record i practice leetcode by just applying to a bunch of jobs and then doing the practices they give me thats the only way to#be motivated to it for me#but yeah if you're thinking about using C++ for competitive programming my advice is know the standard library#inside and out and know how to use it you really wanna use the whole kitchen
24 notes
·
View notes