Logical question: There is a 20-floor tower, and you have 2 plates. At a specific floor, if you throw a plate, it starts to break. If the plate breaks, you can not throw it again, but if it does not break when you throw, you can throw it again.
For example, imagine the floor where it starts to break is 7. So, if I throw the plate lower than the 7th floor, it doesn't break. If I throw it on the 7th or above, it breaks.
The question: How many attempts do I need (in the worst case), to find out the floor that the plate does not break.
Live Coding: There are 2 arrays, both sorted in ascending order.
arr1 = [1,3,5,7,9,0,0,0], m = 5 (the number of non-zero elements)
arr2 = [2,5,8], n = 3 (the number of elements)
The task: You should merge the second array into the first array, and the resulting array should also be sorted in ascending order (you should not create a new result array, but instead modify 1st array). It is guaranteed that the first array has the same number of zeros as the number of elements in the second array. And it does not matter the order if the elements of both arrays are equal, for example, both arrays have element "5", when you compare them, how to sort, it does not matter which stays first.
Result: arr1 = [1,2,3,5,5,7,8,9]