上一页 1 2 3 4 5 6 7 ··· 26 下一页
摘要: Question There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time comp 阅读全文
posted @ 2017-11-10 11:20 清水汪汪 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 1. Question Given n pairs of parentheses, write a function to generate all combinations of well formed parentheses. For example, given n = 3, a soluti 阅读全文
posted @ 2017-11-07 11:50 清水汪汪 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 1. Question Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in th 阅读全文
posted @ 2017-11-07 11:09 清水汪汪 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 1. Question Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives 阅读全文
posted @ 2017-11-07 10:21 清水汪汪 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 1. Question Given a string that consists of only uppercase English letters, you can replace any letter in the string with another letter at most k tim 阅读全文
posted @ 2017-11-05 11:43 清水汪汪 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 1. Question Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000. Example 1: 阅读全文
posted @ 2017-11-05 09:38 清水汪汪 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 1. Question Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the gi 阅读全文
posted @ 2017-11-05 08:57 清水汪汪 阅读(163) 评论(0) 推荐(0) 编辑
摘要: Question 把只包含因子2、3和5的数称作丑数。 Solution 用空间换时间。保存之前生成的丑数,因为之后生成的丑数都是之前的丑数乘上2,3或5得到的。而且只需要,乘上2,3,5以后比当前最大值大的最小值。因此,我们可以标记乘上2,3,5,刚好比最大值大的位置。 Code C++ clas 阅读全文
posted @ 2017-11-02 14:29 清水汪汪 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Solution 动态规划。 f(i)表示包含第i个字符的最长子串。 1. 如果第i个字符没在之前出现过,那么f(i) = f(i 1) + 1 2. 如果第i个字符在之前出现过,这个时候应该分两种情况,假设与之前出现的距离为d,如果d f(i 1) 说明之前出现的字符不在f(i 1)包含的字符串内 阅读全文
posted @ 2017-11-02 12:18 清水汪汪 阅读(193) 评论(0) 推荐(0) 编辑
摘要: Question 输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个。例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为321323。 Solution 数字m和n,两种拼接方式mn和nm,因为长度都一样,所以可以用比较字符串的方式比较他们 阅读全文
posted @ 2017-11-02 09:15 清水汪汪 阅读(251) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 26 下一页