上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 23 下一页
摘要: /* * 121. Best Time to Buy and Sell Stock * 题意:股票买卖1次,最大利润 * 难度:Easy * 分类:Arryas, Dynamic Programming * Tips:lc121, lc309, lc188, lc123, lc714 */ publ 阅读全文
posted @ 2021-04-14 15:35 kpwong 阅读(30) 评论(0) 推荐(0) 编辑
摘要: public static boolean isValidBST(TreeNode root) { if(root==null) return true; return dfs(root, -Double.MAX_VALUE, Double.MAX_VALUE); // 注意Double.MIN_V 阅读全文
posted @ 2021-04-14 15:30 kpwong 阅读(40) 评论(0) 推荐(0) 编辑
摘要: /* * 300. Longest Increasing Subsequence * 题意:最长递增子数组,不一定是连续的 * 难度:Medium * 分类:Binary Search, Dynamic Programming * 思路:基本的思路是dp[i]记录以nums[i]结尾的最长长度,每次 阅读全文
posted @ 2021-04-14 15:24 kpwong 阅读(41) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int[][] generateMatrix(int n) { int maxNum = n * n; int curNum = 1; int[][] matrix = new int[n][n]; int row = 0, column = 0; i 阅读全文
posted @ 2021-04-14 15:20 kpwong 阅读(39) 评论(0) 推荐(0) 编辑
摘要: import java.util.ArrayList; import java.util.List; /* * 119. Pascal's Triangle II * 题意:和118一样,就是输出不一样 * 难度:Easy * 分类:Array * 思路:记一下 ArrayList.set 方法,不 阅读全文
posted @ 2021-04-14 15:14 kpwong 阅读(27) 评论(0) 推荐(0) 编辑
摘要: class Solution { public List<Integer> inorderTraversal(TreeNode root) { List<Integer> res = new ArrayList<Integer>(); inorder(root, res); return res; 阅读全文
posted @ 2021-04-14 15:11 kpwong 阅读(24) 评论(0) 推荐(0) 编辑
摘要: /* * 62. Unique Paths * 题意:求从数组[0,0]走到[m,n]的不同路径数 * 难度:Medium * 分类:Array, Dynamic Programming * 思路:和lc63, lc64思路一样, arr存储的内容由路径数换成了和 */ public class l 阅读全文
posted @ 2021-04-14 15:06 kpwong 阅读(24) 评论(0) 推荐(0) 编辑
摘要: package code; /* * 25. Reverse Nodes in k-Group * 题意:每k个反转一下,不足k的不反转,直接接上 * 难度:Hard * 分类:Linked List * 思路:递归调用反转,反转完下一段的返回节点,节点这一段上 * Tips:lc25, lc206 阅读全文
posted @ 2021-04-14 15:00 kpwong 阅读(31) 评论(0) 推荐(0) 编辑
摘要: // start our "pointer" in the bottom-left class Solution { public boolean searchMatrix(int[][] matrix, int target) { // start our "pointer" in the bot 阅读全文
posted @ 2021-04-14 14:56 kpwong 阅读(29) 评论(0) 推荐(0) 编辑
摘要: import java.util.ArrayDeque; import java.util.ArrayList; import java.util.List; import java.util.Queue; public class lc103 { public class TreeNode { i 阅读全文
posted @ 2021-04-14 14:37 kpwong 阅读(25) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 23 下一页