Round 1: HackerEarth Coding Challenge
1. Given N integers and Q queries. Each query has two integers x and y. Merge two groups containing x and y and output the range of numbers (min and max of N integers) in newly formed group. Initially elements belong to no groups. Solution: simple union-find algorithm.
2. There are N students each with unique student_id. Among those students there are M pairs of students who are friends. Friendship relation is associative (friend(a, b) and friend(b, c) -> friend(a, c)). Students are called and asked to form a line. As a student is called he searches for any friend of his from the end of line and if found, he stands behind that friend, else he stands at the end of line. There are N operations, in each operation there are two queries:
- E x: means student with id x has to stand in line
- D: print student standing in front of line
Solution: Union-find again with some DP for last student_id entered in line belonging to same group.
Round 2: Telephonic Interview
- Give introduction.
- He asked if I had any questions about the role and he explained what kind of project they worked on. They worked on Code Analyzer for Java which was written in C++. He said something about cartography (I don’t know what he meant). He also said they looked into critical violations, security aspects, etc.
- OOPS – difference between composition and aggregation. I couldn’t remember exactly but knew it was something related to inheritance. He later asked if composition and aggregation are same, I said no, they are different. I tried to explain whatever I knew using an example (which turned out to be wrong).
- Virtual functions, virtual inheritance (solution to diamond problem). I didn’t knew much about virtual inheritance. He later asked how virtual functions worked (its mechanism) – I explained about vtables.
- Whether I knew different casts – static, dynamic, const and reinterpret.
- set vs map – I said both are internally same only that set only has keys rather than values.
- unordered_map vs map
I never received any feedback for the interview. I mailed them asking about the status but no reply from them. Very unprofessional! I had to assume that I was not shortlisted.