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 | 688 Views, 23001 Search Bots | 52 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 688 Views, 23001 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 | 688 Views, 23001 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
- Patterns for breaking down questions you haven
- Fibonacci coding
- Daily Interview Problem: Longest Substring With K Distinct Characters
- Progess made
- Daily Interview Problem: Min Range Needed to Sort
- Daily Interview Problem: Maximum Profit From Stocks
- Daily Interview Puzzle: Falling Dominoes
- Find Missing Numbers in an Array
- 56 Bytes
- How to Play WAV music under DOS?
©2006~2024 SteakOverCooked - 0.00786 Seconds(s) - 2490.632 KB/s - 37 Online Memory: 491.61 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 !