|
0
Here is Python code. Time complexity O(n) |
|
0
I try another approach in Problem B. First sort the array then find the max element called it "max", which is last element of array, because we sorted the array. Now we take (n-1) root of "max" called it "r" here "r" may be not integer, so we have to check for two numbers a=floor(r) and b=ceil(r) eg. if r = 5.67 so we take a = 5 and b = 6 now we generate two new power array from this two number and sum of abs different between all element of this array and our sorted array do this for both "a" and "b" and ans will me minimum of this two. |