Global and Local Inversions LeetCode solution in Python

1
class Solution:
2
def isIdealPermutation(self, A: List[int]) -> bool:
3
for i in range(len(A)):
4
if i - A[i] > 1 or i - A[i] < -1:
5
return False
6
return True

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0