Question: What's wrong in this code ? def minOperations(N, A): p=0 min_val = float('inf') ops_count=0 for i in range(N): a = A[i] If a
What's wrong in this code ? def minOperations(N, A): p=0 min_val = float('inf') ops_count=0 for i in range(N): a = A[i] If a<= min_val: p+=1 else: ops_count+=1 del A[p] p = max(0, p-1) min_val= min(min_val, a) N= len (A) if p== N: p = N-1 return ops_count Sample Input: 1 1 Output: 1 Sample Input: 4 1 2 3 4 Output; 4 Note: 1<=N<=10^5 1<=A[i]<=10^9
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
