r/learnprogramming • • 30m ago

What to do !

I know how to write code, but not in the LeetCode style . I also want to do DSA, and my seniors told me to learn a coding language too i know (I already know C, python ). Tell me what all I should do in this situation first .

2 Upvotes

5 comments sorted by

•

u/JohnsTech_dev 25m ago

you dont need another language for dsa, python is fine for leetcode and most interviewers are ok with it. C is painful for it tbh, no hashmap out of the box.

what worked for me was doing problems by topic instead of random ones. like 15 easy array/hashmap problems, then two pointers, then sliding window. if stuck more than 30 min read the solution, close it, and write it again from memory next day

•

u/FinancialTrack5007 19m ago

From where and how to practice DSA .
the main issue is that when i write code in Leetcode in normal way example print int (input()) it shows it as incorrect hope you are understanding this issue

And if i needed to study other lang what would you suggest C++ , java , javascript ?

•

u/a3th3rus 8m ago

LeetCode puzzles have already handled the simple but tedious IO part for you, so that you can focus on the DSA part. If you want to see something, you can print it, but there's no input() in LeetCode. Make sure you delete all the print statements before submitting your code, because print is an IO operation, and IO is slow.

•

u/FinancialTrack5007 0m ago

What i mean is that , there is specific format in which the code has to be written in Leetcode ie "Class solution,-> " honesty from where i learnt python this was not taught to me
how do i handle these type of situations

•

u/a3th3rus 17m ago

Try automating some of your simple but repetitive works. If you don't have one, see if your friends have any that you can help with. For example, my wife (a translator) always have the need for extracting text that needs to be translated from a certain format of XML, and I wrote a Ruby script for that, and another for stuffing the translated text back to that XML.

Also, if you play video games, you can write some algorithm for yourself to minmax something. For example, I've written something that finds the optimal fights in Valkyrie Profile to gain as much exp as possible with no member levels up.