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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!