档案日期2015的9

2015年3月2日 - 2015年3月8日

[LeetCode]Reverse Bits

题目描述:

Reverse bits of a given 32 bits unsigned integer.

For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011110000010100101000000).

Follow up:
If this function is called many times, how would you optimize ...

继续阅读

Python实现整数均分

将整数m划分为n个整数,使得到的整数之间的差值不超过1,结果按照升序排列。

例如输入55, 6,返回[9, 9, 9, 9, 9, 10]。

Python代码:

def splitInteger(m, n):
    assert n > 0
    quotient = m / n
    remainder = m % n
    if remainder > 0:
        return [quotient] * (n - remainder) + [quotient + 1] * remainder
    if remainder ...

继续阅读

每日归档

上周

下周

归档