Cognitree | Interview Experience | SDE 2
- Result
- Rejected
- Posted
- 14 Aug 2025
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.
How it went
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.
Questions asked (5)
- 01
Insert Interval
Data Structures & Algorithms
Given a set of non-overlapping intervals, insert a new interval (merge if needed).
- 02
K Most Frequent Elements
Data Structures & Algorithms
Return the k most frequent elements from an array.
- 03
HashSet Duplicate Check for Custom Objects
Other
Discuss how to ensure that a
HashSet<Student>only stores uniqueStudentobjects (e.g., 'tom' only once) even ifnew Student('tom')is added multiple times. This requires understanding the implementation ofequals()andhashCode()methods. - 04
Longest Substring Without Repeating Characters
Data Structures & Algorithms
Given a string, find the length of the longest substring without repeating characters. Example: "abcabcbb" → 3.
- 05
Longest Substring With At Most 2 Distinct Characters
Data Structures & Algorithms
Given a string, find the length of the longest substring that contains at most 2 distinct characters. Example: "adanm" → 3.