Tap here to switch tabs
Problem
Submissions

Problem: Find if Array Can Be Sorted

Find if Array Can Be Sorted asks whether an array can reach ascending order using adjacent swaps only when both values have the same number of set bits.

Statement

You are given an array of positive integers nums.

In a single operation, you can swap any two adjacent elements if they have the same count of set bits in their binary representation. You are allowed to perform this operation any number of times.

Return true if it is possible to sort the array in ascending order, or false otherwise.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 1≤1 \leq nums[i] ≤28\leq 2^8

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find if Array Can Be Sorted

Find if Array Can Be Sorted asks whether an array can reach ascending order using adjacent swaps only when both values have the same number of set bits.

Statement

You are given an array of positive integers nums.

In a single operation, you can swap any two adjacent elements if they have the same count of set bits in their binary representation. You are allowed to perform this operation any number of times.

Return true if it is possible to sort the array in ascending order, or false otherwise.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 1≤1 \leq nums[i] ≤28\leq 2^8