上一页 1 ··· 170 171 172 173 174 175 176 177 178 ··· 273 下一页
摘要: 拿来主义: 解释如下: timestamp转换为datetime 要把timestamp转换为datetime,使用datetime提供的fromtimestamp()方法: 注意到timestamp是一个浮点数,它没有时区的概念,而datetime是有时区的。上述转换是在timestamp和本地时 阅读全文
posted @ 2018-03-13 12:09 bonelee 阅读(2097) 评论(0) 推荐(0)
摘要: Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Note: The input array will only contain 0 and 1. The length 阅读全文
posted @ 2018-03-12 23:20 bonelee 阅读(206) 评论(0) 推荐(0)
摘要: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l 阅读全文
posted @ 2018-03-12 22:43 bonelee 阅读(250) 评论(0) 推荐(0)
摘要: 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 阅读(440) 评论(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 阅读(194) 评论(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 阅读(188) 评论(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 阅读(283) 评论(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 阅读(220) 评论(0) 推荐(0)
摘要: 高级语法 除了像上面介绍的 [x ** 2 for x in L] 这种基本语法之外,列表推导式还有一些高级的扩展。 4.1. 带有if语句 我们可以在 for 语句后面跟上一个 if 判断语句,用于过滤掉那些不满足条件的结果项。 例如,我想去除列表中所有的偶数项,保留奇数项,可以这么写: >>> 阅读全文
posted @ 2018-03-11 18:33 bonelee 阅读(36172) 评论(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 阅读(450) 评论(0) 推荐(0)
上一页 1 ··· 170 171 172 173 174 175 176 177 178 ··· 273 下一页