In technical interviews, the interviewer is trying to find out if you have good problem solving skills. Some interviewers may ask noncoding questions that describe a specific scenario and want you to come up with a strong solution.
During the interview, don’t be silent and convey your ideas to the interviewer. Imagine the interviewer has presented a user story to you (coding question). He or she has presented the requirements (constraints) and the acceptance criteria (test cases).
- Do you ask relevant questions to break down a bigger problem into smaller problems?
- Do you think about different types of data?
- Do you solve simple test cases first before solving difficult test cases?
For new junior/associate software engineers, you will be asked a classic coding question, “Reverse a string.”
Pretend that you are a detective such as Sherlock Holmes in a short story. You are asked to solve the “Mystery of Reversing a String.” Sherlock Holmes always answers the 5 W’s and H questions to solve the mystery.
Who was involved?
This question is excellent to figure out what specific data is involved with this coding question.
Does this string include uppercase letters? Does this string include lowercase letters? Does this string include numbers? Does this string include special characters? Does this string include empty output?
What happened?
This question determines the starting point and ending point for the scenario. Hopefully there is an existing test case where you see the before and after for the scenario. If there are no existing test cases, I would say aloud the test cases I have in my mind.
When did it happen?
This question will inform you if there is a timing mechanism involved. You may need to add a counter when the string started to reverse.
Where did it happen?
This question is used to find the location of when this scenario occurred. In this case, you can ask possible data structures involving the string.
Did the string reverse in an array?
Why did it happen?
This question is used to determine the factor to why this scenario happened. In this case, the interviewer had a bizarro day and wanted the string to be reversed.
How did it happen?
This question is a great way to find out how did the data got manipulated.
After getting answers to these 6 questions from the interviewer, you can solve the question with more confidence. You can call Police Inspector Jones to close the case.
Who knew that in middle school, you are reading about interview techniques in mystery short stories. I highly recommend reading Sherlock Holmes written by Sir Arthur Conan Doyle.
Photo taken by Chamindu Perera