7 kyu
Most-1-bits
62UK-06
Description:
Given a list of integers(can be positive or negative), find the integer with the highest number of 1 bits in its two's complement binary representation.
Example
most_one_bits([[3, 7, 8, 9, 15]) => #Output: 15 (it has 4 '1' bits)
most_one_bits([3, 7, 8, 9, 23, 28]) => #Output: 23 (it has 4 '1' bits)
In case of a tie, return the last integer in the list with the highest number of 1 bits.
most_one_bits([6, 3, 6, 9, 10]) => #Output: 10 (all have 2 '1' bits
but 10 is the last)
Note:
Integers should be represented in 8 bits
For positive numbers, the calculation of 1 bits in the binary representation remains the same but negative integers will have different results.
most_one_bits([-1,-2,-3]) => #Output -1( it has total of 8 '1' bits)
Duplicates
In case of Duplication of integers only the first occurrence will be considered
Example
most_one_bits([85, 120,-23,-15,-23]) =>#Output -15
( first occurrence of -15 is after first occurrence -23)
Input list will Never be empty( [] )
Fundamentals
Bits
Arrays
Lists
Binary
Similar Kata:
Stats:
Created | Dec 25, 2024 |
Published | Dec 25, 2024 |
Warriors Trained | 124 |
Total Skips | 3 |
Total Code Submissions | 424 |
Total Times Completed | 62 |
Python Completions | 62 |
Total Stars | 2 |
% of votes with a positive feedback rating | 86% of 22 |
Total "Very Satisfied" Votes | 17 |
Total "Somewhat Satisfied" Votes | 4 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 17 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |