Want to give it a shot?? Sign up with us to make sure your upcoming interviews are the best they can be by practicing with our experienced engineers. interviewing.io/signup?.com&
@@soundnarcotics3417 Absolutely not! The interviews we publish are those that both the interviewer and interviewee both gave permission. Let us know if you have any other questions!
The first solution he provided, it has n^2 time complexity... not n as he mentioned. The 2nd problem was not this difficult. If size of both array is m and n, median will be at floor((m+n)/2)th position of marged array. marge both array till (m+n)/2 position (As rest of the items doesn't matter) and peek the last item. You have the solution in linier time complexity.
Your analysis of the first solution is wrong; the time complexity is indeed O(n) because each element in the array and stack is accessed or popped only once. Your solution to the second problem is suboptimal; it can be solved in O(log(min(n, m))) time using binary search.
@@feuerfawkes You are absolutely wrong about the complexity of the first problem. The complexity is indeed O(n^2). How come the stack is accessed and popped only once? Have you tried counting how many times it gets accessed and popped?
That would be a terribly poor reason to fail someone during an interview. The point of an interview is to test your critical thinking and problem solving skills. You could literally teach someone that Deque is more efficient then Java stack in 3 seconds. You can not teach someone how to problem solve and think critically in 3 seconds though.
Want to give it a shot?? Sign up with us to make sure your upcoming interviews are the best they can be by practicing with our experienced engineers. interviewing.io/signup?.com&
If we interview does ours have to be posted on TH-cam?
@@soundnarcotics3417 Absolutely not! The interviews we publish are those that both the interviewer and interviewee both gave permission. Let us know if you have any other questions!
For the first problem, can anyone explain time complexity ( how it is o(n) ). it looks a like n^2 . correct me if i am wrong.
The first solution he provided, it has n^2 time complexity... not n as he mentioned.
The 2nd problem was not this difficult. If size of both array is m and n, median will be at floor((m+n)/2)th position of marged array. marge both array till (m+n)/2 position (As rest of the items doesn't matter) and peek the last item. You have the solution in linier time complexity.
Your analysis of the first solution is wrong; the time complexity is indeed O(n) because each element in the array and stack is accessed or popped only once. Your solution to the second problem is suboptimal; it can be solved in O(log(min(n, m))) time using binary search.
@@feuerfawkes You are absolutely wrong about the complexity of the first problem. The complexity is indeed O(n^2). How come the stack is accessed and popped only once? Have you tried counting how many times it gets accessed and popped?
Interviewer should fail the interviewee for using Java stack. Java stack is known to be inefficient and obsolete, should use Deque instead.
That would be a terribly poor reason to fail someone during an interview. The point of an interview is to test your critical thinking and problem solving skills. You could literally teach someone that Deque is more efficient then Java stack in 3 seconds. You can not teach someone how to problem solve and think critically in 3 seconds though.