摘要:
https://leetcode-cn.com/problems/edit-distance/ 思路一:动态规划来做 public int minDistance(String word1, String word2) { if (word1 == null || word2 == null) re 阅读全文
posted @ 2021-06-27 21:53
syh-918
阅读(29)
评论(0)
推荐(0)
摘要:
https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/ 思路一: 记录买入的最小值,每天卖出的值与最小值买入值做比较得到利润最大值 思路二:动态规划,前后两天相差值组成数组,求子数组最大和 public int maxPro 阅读全文
posted @ 2021-06-27 21:07
syh-918
阅读(44)
评论(0)
推荐(0)
摘要:
https://leetcode-cn.com/problems/li-wu-de-zui-da-jie-zhi-lcof/ 思路:动态规划的思想 public int maxValue(int[][] grid) { int rows = grid.length; int cols = grid[ 阅读全文
posted @ 2021-06-27 18:04
syh-918
阅读(56)
评论(0)
推荐(0)
摘要:
https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/ 思路1 以每个字符为结尾的最长自窜(类似于动态规划)利用上一个最长自窜的位置+上一次出现本字符的位置pi 分为两种就好 pi<li pi> 阅读全文
posted @ 2021-06-27 17:39
syh-918
阅读(46)
评论(0)
推荐(0)
摘要:
https://leetcode-cn.com/problems/reverse-words-in-a-string/ 思路:删除多余的空格,修好一个方法,给一定范围,翻转一定范围的字符串 public static String reverseWords(String s) { if (s == 阅读全文
posted @ 2021-06-27 17:16
syh-918
阅读(47)
评论(0)
推荐(0)
摘要:
https://leetcode-cn.com/problems/valid-anagram/ 思路1 统计字符数哈希表 思路2 使用数组记录出现次数 public boolean isAnagram(String s, String t) { if (s == null || t == null) 阅读全文
posted @ 2021-06-27 17:04
syh-918
阅读(65)
评论(0)
推荐(0)
摘要:
https://leetcode-cn.com/problems/subtree-of-another-tree/ public boolean isSubtree(TreeNode s, TreeNode t) { if (s == null || t == null) return false; 阅读全文
posted @ 2021-06-27 16:44
syh-918
阅读(57)
评论(0)
推荐(0)
摘要:
https://leetcode-cn.com/problems/flipped-string-lcci/ 思路1: 将目标字符串 s1,拼接上自己,判断给的字符串是否是当前拼接字符串的子串; public static boolean isRevolving(String s1, String s 阅读全文
posted @ 2021-06-27 16:38
syh-918
阅读(38)
评论(0)
推荐(0)
摘要:
https://leetcode-cn.com/problems/daily-temperatures/ 思路1: 使用单调递减栈 public int[] dailyTemperatures(int[] T) { if (T == null || T.length == 0) return nul 阅读全文
posted @ 2021-06-27 15:02
syh-918
阅读(47)
评论(0)
推荐(0)
摘要:
https://leetcode-cn.com/problems/maximum-binary-tree/ 思路1:用递归的思想来解决问题 思路2: 利用栈来解决,找出左边第一个比较大值,和右边第一个比较大值,两两比较取大的一个 public TreeNode constructMaximumBin 阅读全文
posted @ 2021-06-27 14:55
syh-918
阅读(46)
评论(0)
推荐(0)
浙公网安备 33010602011771号