
Leetcode
zqxN
这个作者很懒,什么都没留下…
展开
-
Leetcode: Number of 1 Bits
题目:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 0原创 2015-03-15 21:56:37 · 754 阅读 · 1 评论 -
LeetCode:寻找范围
题目描述:给定一个有序数组(如[5, 7, 7, 8, 8, 10]),以及一个目标值(target=8),找出这个目标值在数组中的范围(结果是[3,4]),要求的时间复杂度为O(logN),N表示数组的长度。1、递归解法:比较中间元素(下标为mid)与target的大小,可能出现三种情况,即中间元素等于 target,中间元素小于 target,中间元素大于 target,下面我们分情况讨论:情况原创 2015-09-18 17:37:33 · 518 阅读 · 0 评论