#3769

Sort Integers by Binary Reflection

pupil · 380 · lc easy +24 · 60.8% accepted · 54 likes · top 60%

Description

Given an integer array nums, sort it in ascending order using each element's binary reflection (the decimal value of its reversed binary digits, ignoring leading zeros) as the primary sort key, with ties broken by placing the smaller original number first, and return the resulting sorted array.

Code

1
2
3