Round 1: DSA + Behavioral
Questions:
- Resume questions about projects and technologies used.
- Question: To detect a cycle in a linked list. If detected, return true; if not, return false with proper functions and driver code.
// Example code for cycle detection in a linked list class ListNode { int val; ListNode next; ListNode(int x) { val = x; } } public class Solution { public boolean hasCycle(ListNode head) { ListNode slow = head; ListNode fast = head; while (fast != null && fast.next != null) { slow = slow.next; fast = fast.next.next; if (slow == fast) { return true; } } return false; } }
- Three test cases were provided to run the code.
- Questions about OOP concepts, specifically polymorphism and its types.
Candidate's Approach
I used the hare and tortoise algorithm to solve the cycle detection problem. During the interview, I accidentally deleted the class name while pasting my code into the IDE, which caused an error. After realizing the mistake, I reset the IDE and pasted the code again, which ran successfully. I handled the provided test cases without issues.
Interviewer's Feedback
I received feedback from HR stating that I was rejected due to insufficient debugging skills. Although I answered the theoretical concepts well, my inability to debug the code during the interview was a significant factor in the decision.