Minimum Operations to Make the Array K-Increasing LeetCode solution in Python

1
class Solution:
2
def kIncreasing(self, arr: List[int], k: int) -> int:
3
def LNDS(arr: List[int]) -> int:
4
mono = []
5
for n in arr:
6
if not mono or mono[-1] <= n:
7
mono.append(n)
8
else:
9
mono[bisect_right(mono, n)] = n
10
return len(mono)
11

12
return len(arr) - sum(LNDS(arr[i::k]) for i in range(k))

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0