Python or C++

Hello,
I am an amateur programmer and I have just started learning Data structures and Algos.

  1. Please recommend me learning path for DS and Algorithms in python
  2. I do the code in python, shall I switch to C++ to get better in competitive coding?
  1. You can refer to geeksforgeeks and gain a basic idea about Ds and Algos and I guess you will learn more as you solve problems. If you are a non-cs student, then you may refer to lectures but for cs students, it is in the course curriculum of their subject only.

  2. If you consider CP, then c++ is relatively better due to STL libraries and lesser execution time. In python, generally, a program taking 10 sec time takes almost 2 sec in C++ whereas python is more suited to ML. (each programming language has a particular set of advantage over other).

1 Like

I have started with python it was pretty easy for me to go with it, but when i start moving further i’ve seen that there are much more complex algorithms in the world of CP. while using python i have just used short algos in my code like find count, list methods, string methods etc, using them makes us lazy. Few more points to support c++

  1. In python you don’t have to declare every variable before using it, what should be type of it, which doesn’t help us to observe when to use large integer and when i declared that/this variable. due to this usage of memory is high in python as compared to c++.
  2. Python is an interpreted language so it’s very slow than compiled ones(c/c++, java).
  3. You will face more errors in c++ as your code go long, in each debugging step you will learn some thing new.
    in the point of learning c++ is a good choice, so you may chose c++ for CP…:slightly_smiling_face:
5 Likes

First of all, I am not that great programmer but I do have some thoughts about language preference, If you have time and want to be a successful competitive programmer in future then i must insist to start learning C++ as it is not just fast but also very easy.
I basically use Java as my main language for coding and therefore i face some issues from time to time…
Now you must be thinking that python is more easy than any other language which is absolutely correct but I personally think that you should not code in python especially as a beginner because it make some of the tasks so easy you don’t even give thought about it, and then if in future you want to do the same task in any other language than you can’t because you really don’t know how to implement it from scratch…
What I want to say is that python is good for automation and AI related fields but when it comes to logic building and problem solving skills that i always give more preference to a C++ programmer instead of a python programmer…
Hope it helps…
Happy Coding…

3 Likes

I don’t think this is a specific answer to this because all competitive challenges have time multipliers for python.
I am also confused with this answer till now but cannot find a good answer to it till now.

i am also a beginner and everyone i asked told me to switch to c++ and atleast be able to do all the things that you can do in python(solve atleast 300 questions) and then you have the freedom to choose your own favourite language for CP