上一页 1 2 3 4 5 6 7 8 9 ··· 13 下一页
摘要: 问题描述: ind the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4, 阅读全文
posted @ 2016-08-11 17:21 32ddd 阅读(263) 评论(0) 推荐(0) 编辑
摘要: N皇后的规则:任意两个皇后不在同一行,不在同一列,不在同一斜线上。 算法分析:这种问题就用回溯法。深度搜索然后回溯。用一个数组记录每一行皇后的位置,下标代表行,值代表列。对行深度搜索。 NQueens2:计算有多少种解决方案。 算法分析:用一个成员变量来记录解决方案的个数。 阅读全文
posted @ 2016-08-11 14:34 32ddd 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 问题描述: Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1- 阅读全文
posted @ 2016-08-09 15:32 32ddd 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 算法分析:很显然用递归。但是直接用递归会造成栈溢出,时间复杂度是o(n)。所以要用分治思想,时间复杂度是o(logN)。 阅读全文
posted @ 2016-08-09 14:44 32ddd 阅读(271) 评论(0) 推荐(0) 编辑
摘要: 问题描述:给定一个字符串数组,返回变形词组,变形词是指字母一样但顺序不一样的词。 Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", " 阅读全文
posted @ 2016-08-09 13:26 32ddd 阅读(299) 评论(0) 推荐(0) 编辑
摘要: public class RotateImage { public void rotate(int[][] matrix) { if(matrix.length == 1 && matrix[0].length == 1) { return; } int n = matrix.length; for(int i = 0; i < n-1; i ++) { ... 阅读全文
posted @ 2016-08-08 17:54 32ddd 阅读(253) 评论(0) 推荐(0) 编辑
摘要: JumpGame:给定一个非负整数数组,开始在第一个位置,每个位置上的数字代表最大可以跳跃的步数,判断能不能跳到最后一个位置。 例如:A=[2,3,1,1,4],在位置0处,可以跳一步到位置1,位置1跳3步到位置4. JumpGame2:给定一个非负整数数组,开始在第一个位置,每个位置上的数字代表最 阅读全文
posted @ 2016-08-07 17:28 32ddd 阅读(172) 评论(0) 推荐(0) 编辑
摘要: WildcardMatching:通配符匹配 算法分析: 1. 二个指针i, j分别指向字符串、匹配公式。 2. 如果匹配,直接2个指针一起前进。 3. 如果匹配公式是*,在字符串中依次匹配即可。 注意记录上一次开始比较的位置 Implement wildcard pattern matching 阅读全文
posted @ 2016-08-06 17:37 32ddd 阅读(661) 评论(0) 推荐(0) 编辑
摘要: 问题描述:给定两个字符串,返回他们的乘积。 阅读全文
posted @ 2016-08-05 18:01 32ddd 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 问题描述: Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after ra 阅读全文
posted @ 2016-08-05 16:35 32ddd 阅读(402) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 13 下一页