You are given an integer array nums of length n which represents a permutation of all integers in the range
The number of global inversions is the total number of pairs
nums[i] nums[j]
The number of local inversions is the total number of indices i satisfying:
nums[i] nums[i + 1]
Return true if the number of global inversions equals the number of local inversions, or false otherwise.
Constraints:
n nums.length
nums[i]
All integers in nums are unique.
nums is a permutation of all integers in the range
You are given an integer array nums of length n which represents a permutation of all integers in the range
The number of global inversions is the total number of pairs
nums[i] nums[j]
The number of local inversions is the total number of indices i satisfying:
nums[i] nums[i + 1]
Return true if the number of global inversions equals the number of local inversions, or false otherwise.
Constraints:
n nums.length
nums[i]
All integers in nums are unique.
nums is a permutation of all integers in the range