摘要: Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary representation 阅读全文
posted @ 2018-03-11 22:48 bonelee 阅读(414) 评论(0) 推荐(0)
摘要: Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime comple 阅读全文
posted @ 2018-03-11 22:08 bonelee 阅读(183) 评论(0) 推荐(0)
摘要: You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 ston 阅读全文
posted @ 2018-03-11 21:54 bonelee 阅读(174) 评论(0) 推荐(0)
摘要: Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values. Example 1: Input: 5 O 阅读全文
posted @ 2018-03-11 21:14 bonelee 阅读(259) 评论(0) 推荐(0)
摘要: Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defi 阅读全文
posted @ 2018-03-11 20:32 bonelee 阅读(198) 评论(0) 推荐(0)
摘要: 高级语法 除了像上面介绍的 [x ** 2 for x in L] 这种基本语法之外,列表推导式还有一些高级的扩展。 4.1. 带有if语句 我们可以在 for 语句后面跟上一个 if 判断语句,用于过滤掉那些不满足条件的结果项。 例如,我想去除列表中所有的偶数项,保留奇数项,可以这么写: >>> 阅读全文
posted @ 2018-03-11 18:33 bonelee 阅读(35957) 评论(5) 推荐(13)
摘要: Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: Note: 解法1: 精简版: 解法2: DFS 使用一个数组 阅读全文
posted @ 2018-03-11 17:49 bonelee 阅读(428) 评论(0) 推荐(0)