This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
https://www.geeksforgeeks.org/find-longest-sequence-1s-binary-representation-one-flip/ | |
Input : 1775 | |
Output : 8 | |
Binary representation of 1775 is 11011101111. | |
After flipping the highlighted bit, we get | |
consecutive 8 bits. 11011111111. | |
Input : 12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
You are given a list of integers. Write code to find the majority and minorty numbers in that list. | |
Definition: a majority number is the one appearing most frequently, a minority number appears least frequently. | |
Here is a simple example how it should work: | |
>>> numbers = [1, 2, 2, 3, 2, 3] | |
>>> major_n_minor(numbers) | |
(2, 1) |