JP Morgan & Chase | OA | MANIT Bhopal | SET 2

Question · Posted Jun 2023

 Question 1 The binary cardinality of a number is the total number of 1's it contains in Its binary representation. For example, the decimal integer 2010 corresponds to the binary number 101002. There are 2 1's in the binary representation so its binary cardinality is 2. Given an array of decimal integers, sort it ascending first by binary cardinality, then by decimal value. Return the resulting array. Example n = 4 nums = [1, 2, 3, 4] 110 ----> 12, so ...

The full answer & interview discussion are available to premium members.

Log in Create a free account