This is the transcript of the mock interview with Candidate NG (10+ years)

SDEGuru: Hi NG, Good evening! Welcome to the IM interview. Thank you for taking the time to talk to me.
Candidate NG: I am all set 🙂 Thanks for giving me the opportunity to interview
SDEGuru: You are welcome. What is your favorite programming language?
Candidate NG: C# and now I am also loving Javascript and Typescript
SDEGuru: Nice!
Candidate NG: I recently started working on some front end stuff and came in touch of JavaScript/Typescript
SDEGuru: Which language do you want to use for this interview?
Candidate NG: JavaScript is fine
SDEGuru: Cool! Can you rate yourself in JavaScript on a scale of 1 to 10, 1 = worst, 10 = best ?
Candidate NG: 7
SDEGuru: Why do you say you are a 7? And what will it take to get you from 7 to 8?
Candidate NG: There still some parts of JavaScript that I need to look up on internet for syntax etc…. specially the different kind of for loops. With time I believe javascript syntax will become second nature to me. There are also various frameworks that I need to get familiar with
SDEGuru: Are there any specific areas you want to improve in?
Candidate NG: yes … specially common JavaScript Framework and libraries e.g. Facebook React, Flux, Redux etc. Without these libraries JavaScript development is not very productive
SDEGuru: I see, what is the difference between (a = b), (a == b) and (a===b) in javascript?
Candidate NG: a =b is assignment, a == b is loose comparision and and a === b is strict comparison. We usually never use a == b and always prefer a === b for comparision. In JavaScript there is a concept of truly and falsy.
SDEGuru: Great! Lets jump straight to coding. This is a classic interview question.
SDEGuru: Given write a method numberToLetters(int n), where n is between 0 and 999. Can you print the number in words? so if input is 157 the output will be one hundred fifty seven.
Candidate NG: sure … let me think about it. I can tell you my basic algorithm first. I need to keep some hash sets for 100th, 10s and 1s position, with some special hash set for 11-19

  1. Validate that the input is between 0 and 999
  2. using modules get 100th value, 10th value and 1th value
  3. I am assuming that I need to output only in English words and this need not be localize otherwise localization will make things complex
  4. I need to think for some test cases to see if there are some special cases I am missing as otherwise this question seems very simple

I will also have special case for 0 as 1s place
SDEGuru: Good work on requirement clarification! on #3 Let us assume english. Lets get into coding, if we solve this we will try to extend the question further.
Candidate NG: One more question, what about capitalization of words?
SDEGuru: Great question, well as I said earlier, “so if input is 157 the output will be one hundred fifty seven.”
Candidate NG: So, nothing capitalized, all lower case is good

Candidate NG: I am done with the code … let me run through the test cases manually
SDEGuru: let me know once you are done testing!

Candidate NG: I am done testing.
SDEGuru: Are you sure your code will work for 17? Your fourth test case?
Candidate NG: Let me check again … Yes it should work?

SDEGuru: Really, I think it will print seventeen seven. Wont it?
Candidate NG: Oops, silly mistake, let me fix it.

SDEGuru: What about other test cases?
Candidate NG: I have test it for all cases, I am comfortable with the code.

SDEGuru: Alright, Do you think your code is modular enough? Most logical extension will be to take this to 999,999 or 999,999,999
Candidate NG: I dont think my code is modular, didnt write it that way. But I believe for the problem it was simple enough … I usually make it modular when there is a need … and my unit tests helps me ensure that refactoring did not break anything

SDEGuru: What will you need to change/refactor to make your code modular?
Candidate NG: let me think about it. This basic code will still be used as we still need it for parsing three digits … 99000 will still be “ninety nine” thousand. I can keep dividing the number by 1000 and every time I get a number I have it fall through thousand , million etc. I still need to think about the interface

SDEGuru: This is more of a design question than an implementation, so let us focus on the scenarios. To repeat my question. Do you think your code is reusable? (as is?)
Candidate NG: Yes … for upto 999 yes, if you want to extend it to thousands, million, billion, trillion. let me run through some test scenarios for my design.
Candidate NG:

  • Need to handle special case for “zero”100, 000 // “one hundred” + ” thousand”
  • 127, 123 //”one hundred twenty seven” + ” thousand ” + ” one hundred twenty three “
  • 9, 127, 456
  • 9, 000, 123
  • 99, 000, 000

Post Interview Chat

SDEGuru: How do you think you did?

Candidate NG: I could have done it better on the design question part. As I was not able to write code and took some time in thinking

SDEGuru: Correct, we did rush through it, so don’t be so hard on yourself.

On the positive side:

  • You are very structured, methodical and thorough. I loved the fact that you led with writing test cases
  • And the fact that you started with the array on top
  • The gate checks to defend against bad data is also great
  • Doesnt take much time and shows you are familiar with writing battle tested code
  • You asked thoughtful questions, esp on language limitation/translation needs
    and you restated the problem clearly. +1 for structured thinking.

Candidate NG: Thanks

SDEGuru:

On the down sides:

  • You took a bit longer than i expected to code this up (and test it)
  • You missed the 17 case, despite testing, and despite pointing out.
  • The last design question, you struggled a bit to put it in context. your code is reusable (you didn’t think it was reusable at least not at first)

Candidate NG: I agree. I usually follow YAGNI principal to keep code simple. When I initially designed it I did not think about those scenarios … so my answer was not reusable… when when I thought about the scenarios I found a way to reuse it.

SDEGuru: On the whole, I think it is a good performance. the question was super trivial. i fear, if the question had been a bit more involved you may struggle.

Candidate NG: Thanks for the feedback. At this point I think I need to practice more for speed in interview. I know I can write good code and good design. But need to work on speed for interview purposes

SDEGuru: Spot on! Speed comes with practice. Best of luck with your career.

Comments

comments