Company: UIDAI_22_Dec
Difficulty: medium
Increasing Array Increasing Array Problem Statement You are given a positive integer N , a positive integer K , and an array A of size N such that 1 ≤ A i < 2 K for 1 ≤ i ≤ N . You can perform the following operation on A any number of times: Choose an index i ( 1 ≤ i ≤ N ) and a value x such that 1 ≤ x < 2 K and update the element A i = x . The cost of this operation will be given by the following expression: abs((A i - x) 2 + (A i - x) + (A i ⊕ x) 2 ) The total cost is the sum of individual costs incurred in each operation. Your task is to find the minimum total cost so that after applying the operation (zero or more times), we obtain an increasing array A . An increasing array is defined as an array in which each element is not smaller than the previous element. Formally, A i-1 ≤ A i for 1 < i ≤ N . Notes: abs denotes absolute value. ⊕ is the Bitwise XOR operator. Assume 1-based indexing for the array A . If no operations are applied, the