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, 22982 Search Bots | 52 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 685 Views, 22982 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, 22982 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
- Algorithm Interview: Permutations of numbers
- Find the non-duplicate number
- Daily Interview Problem: Minimum Removals for Valid Parenthesis
- Daily Interview Problem: Reconstrunct Binary Tree from Preorder and Inorder Traversals
- Two Tricks of Delphi
- Consecutive Ones
- Batch Programming in XP
- PHP Unit Tests on VPS Server
- Daily Interview Problem: Queue Using Two Stacks
- Staying on a Chess Board
©2006~2024 SteakOverCooked - 0.00683 Seconds(s) - 2797.963 KB/s - 32 Online Memory: 491.28 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 !