Tap here to switch tabs
Problem
Submissions

Problem: Find if Array Can Be Sorted

med
30 min
Try to solve the Find if Array Can Be Sorted problem.

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

med
30 min
Try to solve the Find if Array Can Be Sorted problem.

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