Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

evil_yodeler's blog

By evil_yodeler, history, 2 years ago, In English

Hello Codeforces, The one with c++ please tell how c++ is better than python excluding compile time and the one with python tell how python is better than c++ especially for cp

  • Vote: I like it
  • -18
  • Vote: I do not like it

| Write comment?
»
2 years ago, # |
  Vote: I like it +24 Vote: I do not like it

python is a snake and c++ is coding language

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Compile time aside,

C++ has good library support like std::set and pbds that python doesn't have. Also, since C++ is more popular. This means that there are a lot of library codes (Atcoder library) and tutorials are mostly in C++. On sites where you can view the codes of others, you have a lot more sample working C++ code than Python code.

Python is very succinct and so you can code stuff up very fast. And you don't have to worry about integer overflow. However you can't go deep in recursion (shallow recursion limit). It's also more widely used in the real world so more applicable for a career.

»
2 years ago, # |
  Vote: I like it +3 Vote: I do not like it

IMO c++ has a better STL library with data structures that support better operations. For instance, take the ordered set in c++. You can easily check element at any index in O(logn) time complexity and it remains sorted. For a python set, it is not that simple to find some element without knowing it already exists in there. Moreover, the set doesn't remain sorted and its not subscriptable.(There are workarounds regarding this problem though, but its simpler and easier in c++)

Another example is the default dictionary in python. It stores the keys in arbitrary order. We have to import separate modules for sorted dictionary and ordered dictionary.

Other than that, python is far more simpler and easier to understand. Even though there will be more references for questions in c++ as compared to python, but one can easily understand and convert code from c++ to python with a little understanding.

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

both have their pros and cons use whatever suits u..good luck

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Actually I have seen people using both during contests. Mostly they prefer C++ though. And one more important point to note, python is opted usually for string problems and C++ for deep recursion problems. Otherwise, at the end of the day it's your skills that matter. So as long as you don't always try to brute force every problem you encounter but instead try to come up with an optimized approach, you are good to go with either of the languages :)

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Python includes : 'P','y','t','h','o','n' But C++ Includes : 'C','+','+'

It means C++ is better. : )

  • »
    »
    2 years ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    It means you are using a multiset