Leetcode 790 Solution
This article provides solution to leetcode question 790 (global-and-local-inversions)
Access this page by simply typing in "lcs 790" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
class Solution: def isIdealPermutation(self, A: List[int]) -> bool: return not any(1 for i, a in enumerate(A) if abs(a - i) > 1)