- This round was a 1-hour coding round scheduled with Software Engineer II working at Affirm.
- For the first 15 minutes, we had a short introduction and technical discussion. I was asked questions about my project and past internship experience. He asked me to share about a recent project I had worked on and technical details on a high level.
- Then, he shared the link for CodePair where I was supposed to take the coding interview. He pasted the question in the editor and asked me to switch to my choice of programming language.
- All major programming languages were supported including C/C++, Java, Python, JavaScript, and many more. I was confident in C++ and moved with that.
- The question was “Given a list of strings, find the shortest unique substring for every string in the list, that appears only in that string”.
- The question was not a standard DSA question but was specifically designed to align with the company’s work. Here’s the link for reference to the detailed problem description: Shortest Unique Substring
- I took a few minutes to understand the question and came up with a simple brute-force approach. The idea was to generate every substring for a given string, beginning with the shortest substring i.e. of one character, and check if it appears in any other given string. If the substring appeared in any other string, break and create a new substring. Otherwise, if the substring is unique then store it in a map with the <original string, substring> as <key, value> pair.
- After narrating my approach, I started implementing it in C++ and I tried to explain the logic behind every function as I wrote them.
- As a follow-up, he asked me how can I further optimize it. But, he asked to take this follow-up as a discussion only and not need to be implemented.
Tips: Always think thoroughly of an approach for the given question before directly diving into implementation. Ask the interviewer for any doubts/edge cases and make sure to walk through the interviewer throughout your code as you write it. Communication is paramount in technical interviews.