上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 25 下一页
摘要: /* 这道题的关键是:动态表尽量的选取,知道二叉搜索树中左子树的点都比根节点小,右子树的点都比根节点大 所以当i为根节点,左子树有i-1个点,右子树有n-i个点,左右子树就可以开始递归构建,过程和一开始的过程是一样的, 而左右子树的特征中可以知道的就是点的个数,所以用点的个数作为动态变量就很好。 这样就给我们提供了一个思路:动态规划... 阅读全文
posted @ 2017-11-29 21:40 stAr_1 阅读(175) 评论(0) 推荐(0) 编辑
摘要: There is an m by n grid with a ball. Given the start coordinate (i,j) of the ball, you can move the ball to adjacent cell or cross the grid boundary i 阅读全文
posted @ 2017-11-22 21:43 stAr_1 阅读(263) 评论(0) 推荐(0) 编辑
摘要: public static int repeatedStringMatch(String A, String B) { //判断字符串a重复几次可以包含另外一个字符串b,就是不断叠加字符串a直到长度大于等于b,叠加一次计数+1 //看现在的字符串是否包含b,包含就返回,不会包含就再叠加一次,因为可能有半截的在后边,再判断,再没有就返回-1 int ... 阅读全文
posted @ 2017-11-06 22:17 stAr_1 阅读(304) 评论(0) 推荐(0) 编辑
摘要: public int minSteps(int n) { /* 由于只能复制全部或者一个,所以: 如果一个数不是质数,那么最快的就是由最大的公因子复制而来 如果一个数是质数,那么所有方式都大于等于全部由1复制而来 网上看了看这个规律都是观察得出的,所以直接背过: 两个键的键盘问题(只能全部复制或者粘贴... 阅读全文
posted @ 2017-11-06 20:14 stAr_1 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 动态规划,二维数组 阅读全文
posted @ 2017-11-05 16:18 stAr_1 阅读(288) 评论(0) 推荐(0) 编辑
摘要: 转自: 很久了就想介绍zotero给大家,而如今还是写的仓促,欢迎大家拍砖~1.你还在为download回来的乱乱的论文发愁吗?从大四写本科毕业论文开始接触文献管理软件,最初用文献管理软件的原因很简单就是能很容易地在word里插入参考文献。而后来需要看的文献逐渐增多,其实还是下载的文件更多了,并且刚 阅读全文
posted @ 2017-10-31 16:39 stAr_1 阅读(33742) 评论(0) 推荐(1) 编辑
摘要: 转自:http://blog.csdn.net/u011092188/article/details/64123561 解决方案: 阅读全文
posted @ 2017-10-25 10:22 stAr_1 阅读(4060) 评论(0) 推荐(0) 编辑
摘要: Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have 阅读全文
posted @ 2017-10-23 22:18 stAr_1 阅读(512) 评论(0) 推荐(0) 编辑
摘要: public int minimumDeleteSum(String s1, String s2) { /* 标准的动态规划题目,难点在于想出将两个字符串删除到相同的过程 这里从两个字符串的开头字符考虑,一个一个得考虑到最后一个,我们用二维数组dp[i][j]代表字符串1前i个字符和字符串2前j个字符实现相同所需要 删除的ASCII ... 阅读全文
posted @ 2017-10-23 22:00 stAr_1 阅读(905) 评论(0) 推荐(0) 编辑
摘要: public boolean canIWin(int maxChoosableInteger, int desiredTotal) { //两种特殊情况,一是目标比最大值小,二是把所有可能取值加起来都没有目标大 if (desiredTotal map = new HashMap(); //为了处理方便,这里下标从1开始,正好和数字对应 ... 阅读全文
posted @ 2017-10-19 19:46 stAr_1 阅读(428) 评论(0) 推荐(0) 编辑
上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 25 下一页