I often get this question from Web devs, "Tanay! if I get a DSA question in an interview can I use C++ or Java or Python to solve it? I am more comfortable in that language for DSA". or another version, "Whether I should solve DSA questions using JavaScript?". This letter will try to address the question.
continuation of series
Before we move ahead, I hope you have signed up for this newsletter. This is 4th in the series of letters I have written around Web/FE interviews and preparation and more are coming:
What all to learn to get a 15LPA+ job as a Frontend fresher?
How much salary should I be expecting based on the checklist?
neogcamp
The series is trying to answer questions that are constantly coming up during the neogcamp. For those who don't know, I am teaching a 6+ month course to turn a beginner into a full stack developer.
Today, we have a guest lecture from Sushil Tripathi, Software Engineer at Microsoft. He's teaching DSA in JavaScript to get students ready for upcoming placements for the camp. While taking preparatory questions from students, this same query came up and this answer documents both mine and his response combined.
the answer
anything is fine
Any language usage should be fine if you're being asked a complex PS/DS question in the interviews. There are two reasons for this:
The questions are asked not to check your JavaScript skill but your problem-solving skill. Generally, there are other interview rounds for checking your FE skills.
Most companies feel that language proficiency can be gained over time but problem-solving skills are necessary to get in and survive. Companies like these generally ask more DSA to FE and they don't mind any language.
do not shift in the middle
Choose one language for solving a question. If you're confident in your JS skills then go for JS. For basic string, array, stack, queue questions, I would suggest you go with JS.
For a simple or complex question, however, if you choose to go with JavaScript then it would create a bad impression to shift in between to Java, Python, or C++. I would advise against shifting in the middle of a question or the round. Worse is using three languages for three different questions.
Therefore, practice well and make up your mind before entering this round. Ideally, there shouldn't be more than 1 round for PS/DS for a web developer. And if you get advanced DSA questions (as an experienced candidate) I would suggest not going through with the process.
Read the whole thread here:

javascript will be impressive
If you're eyeing a high-paying Frontend job, having sound knowledge of JavaScript as a language is a big plus. And what better way to showcase that you have command of the language than putting a Binary Tree or a LinkedList in JavaScript?
Though companies won't judge you negatively if you reach out to a built-in DS in other languages to solve these questions, it sure would be impressive if you whip it out in JavaScript during the interview.
my own interview
This brings me to my own interview for Microsoft. I was not interviewed heavily on DSA as I was interviewing for an experienced FE role. However, the tree question which I got, I quickly solved it using JavaScript. TBH, I had practiced all Data Structures in JavaScript before going for the interview. And I honestly, again, personal opinion, don't understand why people struggle with implementing DS in JavaScript. I think I don't understand cuz I have never done competitive programming.
Anyway, coming back to the topic, when I joined Microsoft I met my interviewer and he told me that he was quite impressed by my interview for three things, one of that was solving DS questions using JavaScript. The other two, I am keeping for a relevant letter someday.
The point I am trying to make is any experienced JS dev (including me) will get slightly impressed if you solve all PS/DS questions in JS. However, notice the word: slight
. Don't jeopardize your whole interview for this small advantage. Only do this if, like me, you are confident in your JS skills and have practiced it before.
A small favor to ask. I have been writing regularly. Striving to bring clarity over the whole JS interview and career scenario. It would be great if you can share it on social media, or just forward this email to at least ONE friend asking her to sign up for the letter.
Also, I’ll be waiting for your comments to take this discussion forward. I love talking to everyone in the comments, it gives a warm feeling of community dialogue. Thank you for that. ❤️❤️
Thank you for an elaborate answer, actually I asked that Qs in LinkedIn comments that day 😄
"The other two, I am keeping for a relevant letter someday " - Tanay Sir building suspense like Web Series 😂
I have been using Javascript to solve DA questions recently and this question has evolved a few times like should i do this in any other language but after reading this I will continue with JS as its a beautiful language and i am very much comfortable with it. Thank you for the post Tanay! 👍