Amazon
Anonymous User
2107
  1. Find the minimum operations to be performed on the array to have maximum element in the sliding window of 3 to be greater than K. The only allowed operation would be to increase the element by 1.

Example :
Input : array = [1, 3, 0, 3, 1] , K=5
Output: 4
Explanation : Increasing the element at index (0-based Index) 1 and 3 two times.

  1. Find the minimum number that can be XOR-ed to each element in the given sorted array to arrange the array to be sorted in descending order

Input : [2, 2, 4, 5]
Output : 5
Explanation : If each element is XOR-ed with 5, will yield the following array : [7, 7, 3, 0]

Could someone please help with the approach ?

Comments (8)