摘要: key: build and search Hash table. following up questions: Overflow value for target? 用Hash table记录之间的状态,思想类似DP def twoSum(nums, target): d = {} n = len(nums) res = [] for i in range... 阅读全文
posted @ 2016-12-13 03:38 lettuan 阅读(93) 评论(0) 推荐(0) 编辑
摘要: Q: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a sing 阅读全文
posted @ 2016-12-13 03:35 lettuan 阅读(188) 评论(0) 推荐(0) 编辑
摘要: Example: Example: 阅读全文
posted @ 2016-12-13 03:33 lettuan 阅读(116) 评论(0) 推荐(0) 编辑
摘要: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the 阅读全文
posted @ 2016-12-11 13:52 lettuan 阅读(139) 评论(0) 推荐(0) 编辑
摘要: Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example, If n = 4 and k = 2, a solution is: L15-L16 判段一下 阅读全文
posted @ 2016-12-09 04:16 lettuan 阅读(170) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both 阅读全文
posted @ 2016-12-03 05:13 lettuan 阅读(129) 评论(0) 推荐(0) 编辑
摘要: Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or 阅读全文
posted @ 2016-12-03 02:36 lettuan 阅读(170) 评论(0) 推荐(0) 编辑
摘要: Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes 阅读全文
posted @ 2016-12-02 13:09 lettuan 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For exa 阅读全文
posted @ 2016-11-29 14:30 lettuan 阅读(101) 评论(0) 推荐(0) 编辑
摘要: Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum pro 阅读全文
posted @ 2016-11-27 12:02 lettuan 阅读(98) 评论(0) 推荐(0) 编辑