You are given an integer array nums where each element is locked of the same length, where locked[i] == 1 indicates that index i is locked and locked[i] == 0 indicates that index i is unlocked.
You can perform the following operation any number of times:
Choose an unlocked index i such that nums.length nums[i] nums[i + 1] nums[i] with nums[i + 1].
You may unlock any number of locked indices by changing their corresponding value in locked from
Return the minimum number of indices that must be unlocked so that nums can be sorted in nondecreasing order. If it is impossible to sort nums, return
Constraints:
nums.length
nums[i]
locked.length nums.length
locked[i]
You are given an integer array nums where each element is locked of the same length, where locked[i] == 1 indicates that index i is locked and locked[i] == 0 indicates that index i is unlocked.
You can perform the following operation any number of times:
Choose an unlocked index i such that nums.length nums[i] nums[i + 1] nums[i] with nums[i + 1].
You may unlock any number of locked indices by changing their corresponding value in locked from
Return the minimum number of indices that must be unlocked so that nums can be sorted in nondecreasing order. If it is impossible to sort nums, return
Constraints:
nums.length
nums[i]
locked.length nums.length
locked[i]