During the interview I was given two coding questions based on DSA. I was asked to explain my approach, write up the code and say the time & space complexities for the solution I gave.
Coding Question #1:
Find the minimum in rotated and sorted array.
Input: [5, 7, 8, 1, 2]
Output: 1
Coding Question #2:
Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.
Input: [1, 2, 3]
Output: 3
Explanation:
Only three moves are needed (remember each move increments two elements):
[1, 2, 3] => [2, 3, 3] => [3, 4, 3] => [4, 4, 4]
Finally she asked me to explain about merge sort and quick sort (it's approach, time complexity, differences between the two & which one is better for different situations)