Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started