Cognitree | Interview Experience | SDE 2
Summary
I interviewed for an SDE 2 position at Cognitree, facing a mix of DSA, Java, and OOPS questions. Although I performed well on most DSA problems, I was ultimately rejected after struggling with a specific HashSet conceptual question.
Full Experience
I recently interviewed for an SDE 2 role at Cognitree, and the process consisted of two rounds.
In the first round, the focus was entirely on Data Structures and Algorithms. I was given two problems: 'Insert Interval' and 'K Most Frequent Elements'. I was able to provide complete solutions for both, and felt that this round went very smoothly for me.
The second round was a combination of Java, OOPS, and DSA. We had discussions around core Java concepts, OOPS principles, and SOLID principles. A specific problem involved understanding how HashSet handles duplicate custom objects, requiring knowledge of equals() and hashCode(). Additionally, I was presented with two more DSA problems: 'Longest Substring Without Repeating Characters' and 'Longest Substring With At Most 2 Distinct Characters'.
I felt confident about my DSA solutions in the second round as well. However, I realized afterward that I had missed the precise explanation for the HashSet duplicate scenario, which was a critical point. This experience taught me the importance of always recalling the behavior of equals() and hashCode() methods for such cases. Unfortunately, I received a rejection, which I believe was primarily due to my struggle with that particular conceptual question.
Interview Questions (5)
Insert Interval
Given a set of non-overlapping intervals, insert a new interval (merge if needed).
K Most Frequent Elements
Return the k most frequent elements from an array.
HashSet Duplicate Check for Custom Objects
Discuss how to ensure that a HashSet<Student> only stores unique Student objects (e.g., 'tom' only once) even if new Student('tom') is added multiple times. This requires understanding the implementation of equals() and hashCode() methods.
Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. Example: "abcabcbb" → 3.
Longest Substring With At Most 2 Distinct Characters
Given a string, find the length of the longest substring that contains at most 2 distinct characters. Example: "adanm" → 3.