3644. Maximum K to Sort a Permutation
You are given an integer array
numsof lengthn, wherenumsis a permutation of the numbers in the range[0..n - 1].You may swap elements at indices
iandjonly ifnums[i] AND nums[j] == k, whereANDdenotes the bitwise AND operation andkis a non-negative integer.Return the maximum value of
ksuch that the array can be sorted in non-decreasing order using any number of such swaps. Ifnumsis already sorted, return 0.
1 | class Solution { |