摘要: 题目如下: https://leetcode.cn/problems/middle-of-the-linked-list/description/ Java代码如下: ` class ListNode { int val; ListNode next; ListNode() {} ListNode( 阅读全文
posted @ 2024-12-29 21:15 hhh_666 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 题目如下: https://leetcode.cn/problems/house-robber/submissions/585584971/?envType=study-plan-v2&envId=dynamic-programming 思路:动态规划 Java代码如下: ` import java 阅读全文
posted @ 2024-12-07 12:10 hhh_666 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 题目如下: https://leetcode.cn/problems/min-cost-climbing-stairs/?envType=study-plan-v2&envId=dynamic-programming 思路:动态规划 Java代码如下: `import java.util.Scann 阅读全文
posted @ 2024-12-07 11:07 hhh_666 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 题目如下: https://leetcode.cn/problems/n-th-tribonacci-number/description/?envType=study-plan-v2&envId=dynamic-programming 思路:动态规划 Java代码如下: `import java. 阅读全文
posted @ 2024-12-06 19:14 hhh_666 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 题目如下: https://leetcode.cn/problems/climbing-stairs/description/?envType=study-plan-v2&envId=dynamic-programming 思路:动态规划。关键是找到递推关系,写出动态规划的转移方程。 Java代码如 阅读全文
posted @ 2024-12-06 19:03 hhh_666 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 题目如下: https://leetcode.cn/problems/fibonacci-number/?envType=study-plan-v2&envId=dynamic-programming 思路:动态规划 Java代码如下: `import java.util.Scanner; publ 阅读全文
posted @ 2024-12-06 18:46 hhh_666 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 题目: https://leetcode.cn/problems/binary-tree-inorder-traversal/description/ 思路:中序遍历非递归算法 Java代码如下: import java.util.*; class TreeNode { int val; TreeN 阅读全文
posted @ 2024-12-04 13:11 hhh_666 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 题目: https://leetcode.cn/problems/length-of-last-word/description/ 思路:正则表达式、Pattern对象、Matcher对象 Java代码: import java.util.ArrayList; import java.util.Ar 阅读全文
posted @ 2024-12-04 12:34 hhh_666 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 题目: https://leetcode.cn/problems/search-insert-position/description/ 思路:二分查找 Java代码: import java.util.Scanner; class Solution { public static void mai 阅读全文
posted @ 2024-12-04 11:18 hhh_666 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 题目: https://leetcode.cn/problems/find-the-index-of-the-first-occurrence-in-a-string/description/ 思路:使用KMP算法 Java代码如下: import java.util.Scanner; class 阅读全文
posted @ 2024-12-04 10:45 hhh_666 阅读(12) 评论(0) 推荐(0) 编辑