2016年9月5日

动态规划 最长回文子串 leetcode5

摘要: public static String longestPalindrome(String s) { if(null==s||s.length()==0) return s; int n=s.length(); char[]c=s.toCharArray(); int[][]dp=new int[n][n]; ... 阅读全文

posted @ 2016-09-05 15:26 todayjust 阅读(271) 评论(0) 推荐(0) 编辑

动态规划 两个字符串之间的编辑距离 leetcode72

摘要: public static int minDistance(String word1, String word2) { char[] s1 = word1.toCharArray(); char[] s2 = word2.toCharArray(); int len1 = s1.length; ... 阅读全文

posted @ 2016-09-05 15:24 todayjust 阅读(304) 评论(0) 推荐(0) 编辑

动态规划 选择硬币使得价值最大

摘要: 动态规划 第一个人每次都选择 当前+之后可以拿到的 最大的值 当第一个人选择完成后,第二个人用同样的策略拿剩下的硬币中 当前+之后可以拿到的 最大的值 用dp[i][j]记录在还剩v[i]~v[j]时,先拿的人可以最多拿多少钱 用record[i][j]记录在还剩v[i]~v[j]时,先拿的人选择了 阅读全文

posted @ 2016-09-05 15:21 todayjust 阅读(911) 评论(0) 推荐(0) 编辑

导航