File: root - text - article - 2020 - 02 - consecutive-ones.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 705 Views, 24079 Search Bots | 52 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 705 Views, 24079 Search Bots | 52 Words
| Browse | Archive
Hi, here's your problem today. This problem was recently asked by Microsoft:
Return the longest run of 1s for a given integer n's binary representation.
Example:
Input: 242
Output: 4
242 in binary is 0b11110010, so the longest run of 1 is 4.
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 705 Views, 24079 Search Bots | 52 Words Return the longest run of 1s for a given integer n's binary representation.
Example:
Input: 242
Output: 4
242 in binary is 0b11110010, so the longest run of 1 is 4.
def longest_run(n):
# Fill this in.
print longest_run(242)
# 4
Related Articles
- Generate All IP Addresses
- Top K Frequent words
- Binary Tree Level with Minimum Sum
- Daily Interview Puzzle: Falling Dominoes
- Algorithm Interview: Smallest Number that is not a Sum of a Subset of List
- Invert a Binary Tree
- Absolute Path
- Daily Interview Puzzle: Minimum Size Subarray Sum
- PHP Unit Tests on VPS Server
- [Daily Problem] Angles of a Clock
©2006~2024 SteakOverCooked - 0.00678 Seconds(s) - 2780.588 KB/s - 12 Online Memory: 490.83 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !