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 | 685 Views, 22962 Search Bots | 52 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 685 Views, 22962 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 | 685 Views, 22962 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
- Daily Interview Problem: Trapping Rainwater
- Daily Interview Problem: Room scheduling
- Skip the readings, focus on problems. And use all the hints!
- Print a tree level-by-level, with line-breaks
- Daily Interview Question: Edit Distance
- Daily Interview Problem: Largest BST in a Binary Tree
- Daily Interview Problem: Group Words that are Anagrams
- Patterns for breaking down questions you haven
- Most Frequent Subtree Sum
- 56 Bytes
©2006~2024 SteakOverCooked - 0.00726 Seconds(s) - 7382.866 KB/s - 46 Online Memory: 527.39 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 !