Can Array Be Sorted With Adjacent Swaps?
Can sort array if adjacent elements with same set bits can be swapped and sorted individually
3011. Find if Array Can Be Sorted Difficulty: Medium Topics: Array, Bit Manipulation, Sorting You are given a 0-indexed array of positive integers nums. In one operation, you can swap any two adjacent elements if they have the same number of set bits1. You are allowed to do this operation any number of times (including zero). Return true if you can sort the array, else return false. Example 1: Input: nums = [8,4,2,30,15] Output: true Explanation: Let's look at the binary representation of every element. The numbers 2, 4, and 8 have one set bit each with binary representation "10", "100", and...