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 | 684 Views, 22936 Search Bots | 52 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 684 Views, 22936 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 | 684 Views, 22936 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
- Absolute Path
- Daily Interview Problem: Decode String
- Daily Interview Problem: Spiral Traversal of Grid
- Spreadsheet Column Title
- Binary Tree Level with Minimum Sum
- CVE-2015-8874 - cPanel EasyApache Vulnerabilities
- Design Tic-Tac-Toe
- Daily Interview Problem: Validate Binary Search Tree
- Floor and Ceiling of a Binary Search Tree
- Daily Interview Problem: Room scheduling
©2006~2024 SteakOverCooked - 0.00717 Seconds(s) - 2727.678 KB/s - 324 Online Memory: 492.56 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="index, 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 !