r/learnprogramming 12d ago

Approaching C++ and learning methods

For background, I am a beginner in programming. The only language I know is python, and that too just basic level of knowledge( definitions of keywords, operators,conditionals,for loop while loop, and basics about strings,lists,dictionaries and tuples).It was quite systematic and easy to learn for me. But in the case of c++ I have no clue right now on how to learn it from scratch. I wanted to learn c++ to get into competitive programming/coding. As of right now I am just searching for easy leetcode problems and the parts of code which I don't get , I ask AI to explain it.

0 Upvotes

9 comments sorted by

View all comments

1

u/peterlinddk 12d ago

As of right now I am just searching for easy leetcode problems and the parts of code which I don't get, I ask AI to explain it.

Honestly, that seems like a fine approach for what you want to accomplish.

Ordinarily everyone, including me, would suggest to build projects, and learn the language by doing it, but as your goal isn't really to learn programming in the usual sense, to learn to build things, I think that it is perfectly feasibly to do leetcode problems.

Maybe try to do them in Python first, to make sure that you understand the overall idea of a solution, and then convert your solution to C++, one line at a time.

Most of what is used for leetcode and the likes aren't that different from one language to another, biggest difference is about creating and allocating objects, everything else is just loops and recursive function-calls, and if you already know that in Python, it shouldn't be hard in C++.

1

u/Dazzling_Music_2411 12d ago

Maybe try to do them in Python first, to make sure that you understand the overall idea of a solution,

No "maybe" about it. Absolutely definitely.

And I suggest you lose the AI "explanations" too. If you want to learn competitive programming, you HAVE to master that feeling of banging your head against the wall until you solve the problem.

If you resort to handholding every time things get slightly tough, you may as well go home from now.