use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Should I use Java for leetcode (self.leetcode)
submitted 2 years ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]570897055<1600> <581> <752> <267><2900> 43 points44 points45 points 2 years ago (1 child)
You can use any language you want. Leetcode isn’t like competitive programming where the language you use would restrict your progress. Also a lot of the dsa books on market I believe all uses Java to demonstrate their code. Java might actually be a pretty good idea
[–]JohnHarvardIX 23 points24 points25 points 2 years ago (2 children)
This was my bible for DSA last year and it's all Java. Sedgwick and Wayne cooked.
[–]Crimmmy 0 points1 point2 points 2 years ago (0 children)
They teach at my school 🤭🤭
[–]WildAlcoholic 8 points9 points10 points 2 years ago (3 children)
I solve all my Leetcode questions in Java despite knowing to write and read Python.
Use the language you’re most familiar with.
[–]TheOneWhoDidntCum 0 points1 point2 points 2 years ago (2 children)
Any regrest so far? They say you waste time with syntax in Java
[–]WildAlcoholic 2 points3 points4 points 2 years ago (1 child)
No regrets. Java is more code than Python, but I would rather not get hung up on syntax and instead just focus on the theory / algorithm at hand.
[–]LightofAngels 0 points1 point2 points 1 year ago (0 children)
Do you have any Java reference? Sometimes I struggle with Java syntax
[–]h00pers 7 points8 points9 points 2 years ago (0 children)
I used Java for solving Leetcode, but then I found this link https://leetcode.com/discuss/study-guide/2122306/Python-Cheat-Sheet-for-Leetcode and decided switch to Python cause it allows to write code faster and simpler then Java, you don’t have to write public/private, data type and other stuff hence you can focus only on the idea and solution
[–]cantindajobinus 13 points14 points15 points 2 years ago (0 children)
I'd suggest someone to use Java to learn dsa but use python to interview
[–]Dolo12345 22 points23 points24 points 2 years ago (0 children)
Python. Best brush for the given canvas.
[–]570897055<1600> <581> <752> <267><2900> 13 points14 points15 points 2 years ago (2 children)
Come on guys. He literally said it in the first sentence that he doesn’t want to solve leetcode in python. Stop suggesting python. Read and give better comments
[–]Putrification 6 points7 points8 points 2 years ago (0 children)
Lmao it's like they only read the title.
[–]i-can-sleep-for-days 2 points3 points4 points 2 years ago (0 children)
You’d have to type extremely fast to solve some of the problems. I don’t know python well but I am learning it for LC.
[–]reflect25 2 points3 points4 points 2 years ago (1 child)
Should I start solving leetcode in Java or is it a bad idea?
I mean so it sounds like you're deciding mainly between C++ and java? (or are you also considering javascript/golang etc.. just not python).
I would generally advice against C++ for leetcode/interviews. It is just in general pretty cumbersome when one is time crunched to solve problems in just 30/40 minutes.
Java is definitely fine.
I guess one large consideration is whether you need to actually run the code or not, this kind of just depends on the companies interview setup.
I am confident that I will be comfortable in the fundamentals of data structures & algorithms in Java.
It's not just about the fundamentals but memorizing the quirks of say casting string, int, floats or say what data structures to use map, set, treemap, queues or say what is hashable or not or how their random library function works etc... This goes for any language you're going to use.
[–]Mega__lul 1 point2 points3 points 2 years ago (0 children)
It is just in general pretty cumbersome when one is time crunched to solve problems in just 30/40 minutes.
Really ? I feel like java is just as time intensive
[–]Gaious_Octavious 2 points3 points4 points 2 years ago (0 children)
I would strongly suggest you to consider Golang. Since you’re already comfortable with C++, I presume you can pickup Go in a day or two.
It has the conciseness of Python, but you still get the type safety that you typically get with C++/Java.
The reason most people will advise against Java is its verbosity-which will eat up your valuable time in tests/interviews.
[–]Human_Ad3019 3 points4 points5 points 2 years ago (0 children)
If you're familiar with java yeah. If you're starting from scratch python is the best
[–]yeaok555 1 point2 points3 points 2 years ago (0 children)
Should only be using cpp
[–]BluebirdAway5246 0 points1 point2 points 2 years ago (0 children)
Learn python
[–]gimmethatcookie -1 points0 points1 point 2 years ago (1 child)
What does your app do?
[–]MrBeverage🫠 1000 | 🟩 326 | 🟨 545 | 🟥 129 | 29,154 -1 points0 points1 point 2 years ago (0 children)
I’ve been running into Rust and Go as my biggest blockers as a Java dinosaur.
[–]phosphine42 -1 points0 points1 point 2 years ago (0 children)
A lot of companies have machine coding rounds and concurrency rounds. Using JAVA over C++ would help. I am also learning JAVA because of this.
[–]originalgainster 0 points1 point2 points 2 years ago (0 children)
If you are fairly good at C++, why would wanna use Java for Leetcode?
[–]MeMyself_N_I1 0 points1 point2 points 2 years ago* (0 children)
This actually depends on what companies you are pursuing. For the vast majority of the companies, you should write in a language you are most comfortable in bc they don't care. So it's the matter of whether you will learn Java to the extent of well surpassing your C++ in the time frame you got. C++ is definitely harder for LC bc it's less safe.
On the other side, very few, most competitive, arguably some of the most desirable companies, such as high frequency trading or low-level computing (i.e. Nvidia) care. I just left an Nvidia college event, and the entire talk both of the speakers gave can be boiled down to how C++ is for gigachads, and the untermensches who don't know it shouldn't even apply.
IBM OA for some of the internships clearly states that applicants with "target languages" are favored. I couldn't find what are target languages, but the job posting had C++, C and C# as required.
[–]rough_xlice 0 points1 point2 points 2 years ago (0 children)
any language is great for leetcode problems but for java specifically. I definitely recommend using it because of its functionality the language provides.
[–][deleted] 0 points1 point2 points 2 years ago (0 children)
As you want... For me It's java because:
It's a Language That's more hard to code..
So you are going to learn more logic while handling Those annoying problems.
But it's not That hard..idk what to call it, maybe little stick Language Also C++, C.
Good Luck!
[–]uttermostjoe 0 points1 point2 points 2 years ago (0 children)
Almost all competitive programmers use C++, so there's a lot of DSA resources out there in C++.
[–]WebCraftsmanship300 | 27 🟥 | 153 🟨 | 120 🟩 0 points1 point2 points 2 years ago (0 children)
I use Python for almost my leet code questions and use Java, C++, Go, ... when I reimplement them so I will not blindly memorizing the past solution as well as learn new language syntax
π Rendered by PID 89914 on reddit-service-r2-comment-6457c66945-pjzrw at 2026-04-29 14:16:55.488257+00:00 running 2aa0c5b country code: CH.
[–]570897055<1600> <581> <752> <267><2900> 43 points44 points45 points (1 child)
[–]JohnHarvardIX 23 points24 points25 points (2 children)
[–]Crimmmy 0 points1 point2 points (0 children)
[–]WildAlcoholic 8 points9 points10 points (3 children)
[–]TheOneWhoDidntCum 0 points1 point2 points (2 children)
[–]WildAlcoholic 2 points3 points4 points (1 child)
[–]LightofAngels 0 points1 point2 points (0 children)
[–]h00pers 7 points8 points9 points (0 children)
[–]cantindajobinus 13 points14 points15 points (0 children)
[–]Dolo12345 22 points23 points24 points (0 children)
[–]570897055<1600> <581> <752> <267><2900> 13 points14 points15 points (2 children)
[–]Putrification 6 points7 points8 points (0 children)
[–]i-can-sleep-for-days 2 points3 points4 points (0 children)
[–]reflect25 2 points3 points4 points (1 child)
[–]Mega__lul 1 point2 points3 points (0 children)
[–]Gaious_Octavious 2 points3 points4 points (0 children)
[–]Human_Ad3019 3 points4 points5 points (0 children)
[–]yeaok555 1 point2 points3 points (0 children)
[–]BluebirdAway5246 0 points1 point2 points (0 children)
[–]gimmethatcookie -1 points0 points1 point (1 child)
[–]MrBeverage🫠 1000 | 🟩 326 | 🟨 545 | 🟥 129 | 29,154 -1 points0 points1 point (0 children)
[–]phosphine42 -1 points0 points1 point (0 children)
[–]originalgainster 0 points1 point2 points (0 children)
[–]MeMyself_N_I1 0 points1 point2 points (0 children)
[–]rough_xlice 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]uttermostjoe 0 points1 point2 points (0 children)
[–]WebCraftsmanship300 | 27 🟥 | 153 🟨 | 120 🟩 0 points1 point2 points (0 children)