Round 1: (DSA & Technical)
Questions:
-
Given the following JavaScript code snippet, debug it:
var temp = 'hi'; function display() { console.log(temp); var temp = 'bye'; }; display();
-
Follow-up question: What happens if
var
is replaced bylet
? -
Explain JavaScript hoisting.
-
What is the Virtual DOM?
-
DSA question: Given the array
arr[] = {1, 6, 11, 16, 21, 31};
which has an arithmetic mean series, find the missing element (except the first and last).private static int func(int[] arr) { int i = 0; int len = arr.length; int diff = (arr[len - 1] - arr[0]) / (len); for(i = 0; i < len - 1; i++) { if(arr[i] + diff != arr[i + 1]) { break; } } return arr[i] + diff; } public static void main(String []args){ int arr[] = {1, 6, 11, 16, 21, 31}; int res = func(arr); System.out.println(res); }
- Time complexity: O(N)
- Space complexity: O(1)
-
Further optimization was requested, and the candidate explained a binary search approach.
- Time complexity: O(log N)
- Space complexity: O(1)
-
Another DSA question: Count distinct occurrences as a subsequence.
- Input:
S = banana
,T = ban
, Output: 3 - Input:
S = Sosasossos
,T = sos
, Output: 6
- Input:
-
How does GitHub update code in real-time without refreshing?
Candidate's Approach
The candidate explained a brute force approach for finding the missing element in the arithmetic mean series. They also discussed a binary search approach for optimization. However, they struggled with the distinct subsequence question and the real-time update question.
Interviewer's Feedback
No feedback provided.
Round 1: (DSA & Technical) - Update
Questions:
- Product Array except self (LeetCode)
- Median of Running data stream (LeetCode)
- Design a counter in React JS with CSS that blocks increment/decrement actions for 5 seconds.
Candidate's Approach
The candidate completed the DSA questions but struggled with implementing setInterval()
for the React JS question. They managed to implement some CSS but were not able to complete the entire functionality.
Interviewer's Feedback
No feedback provided.