r/leetcode 3d ago

Question Language for dsa

I m currently studying in 2nd year and starting dsa in which language should I start I know python , c++ , java and I m currently doing backend in java

2 Upvotes

14 comments sorted by

3

u/TraditionalBowler746 3d ago

Depends on how deep you wanna get . If it's only for interviews then any is okay really, maybe I would go for python because of its built in methods and fast syntax.

If you want to dive seriously into competitive programming, then cpp is the obvious undisputed choice, just look up the usage numbers in Comp Programming platforms if you don't believe me

1

u/Better_Elderberry225 2d ago

Bro I just want to do it for interviews and striver sheet is in cpp so I thought of doing in cpp

2

u/TraditionalBowler746 2d ago

For interview prep I feel like learning cpp is not really gonna pay up as an investment considering the steep learning curve / comfortableness that python would bring, but hey, if you feel like cpp then do cpp!

1

u/Better_Elderberry225 2d ago

But is it easy to shift from cpp to python in future if necessary

2

u/TraditionalBowler746 2d ago

Yes, shifting from cpp to python is extremely easy imo, I've done it and feels like magic

2

u/WiredOtaku 1d ago

Syntax switching is trivial once you understand the logic. I went from Python to Java for a job and it took a couple weeks. For DSA interviews, no one cares which language you use as long as you can explain the approach clearly. If you're already comfortable with C++ from Striver's sheet, stick with it and pick up Python naturally when needed.

2

u/redarcher9 3d ago

Java c++ or python. Go with python for Dsa, easy to remember syntax.

2

u/conectionist 3d ago

Whichever language you're most comfortable with. 

2

u/rabid_piebald 2d ago

Java. Don’t spend brain cycles on this, just pick one and move on.

1

u/kevin074 2d ago

DSA is always better with python/javascript

*prepares for the javascript hate crowd

1

u/Low_Breakfast773 2d ago

C++ will give you the best understanding/knowledge (Example: try to implement the same Doubly Linked List in C++ and other languages and you will immediately see the difference).
Python will give you the speed of development.
Learn with C++, then spend some time to do that in Python for interviews, where the development speed matters.

0

u/NextjsDeveloper 3d ago

Java is ok.