To the Top
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 | 450 Views, 21619 Search Bots | 52 Words

Subscribe to Feed Burner | 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.


def longest_run(n):
# Fill this in.

print longest_run(242)
# 4
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 450 Views, 21619 Search Bots | 52 Words Subscribe to Feed Burner

Related Articles

  1. Daily Interview Problem: Largest Product of 3 Elements I
  2. Algorithm Interview: Lowest Common Ancestor of 2 Nodes in Binary Tree
  3. Algorithm Interview Question: H-Index
  4. First and Last Indices of an Element in a Sorted Array
  5. [Daily Problem] Remove Consecutive Nodes that Sum to 0
  6. Design Tic-Tac-Toe
  7. Daily Interview Question: Longest Sequence with Two Unique Numbers
  8. Algorithm Interview: Permutations of numbers
  9. Non-decreasing Array with Single Modification
  10. Daily Interview Problem: Maximum Profit From Stocks

Comments (0)

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />