上一页 1 ··· 5 6 7 8 9 10 11 12 13 14 下一页
摘要: 题目链接 递归 class Solution { public int uniquePaths(int m, int n) { return dfs(new HashMap<Pair,Integer>(),0,0,m,n); } private int dfs(Map<Pair,Integer> c 阅读全文
posted @ 2022-02-07 01:55 蹇爱黄 阅读(32) 评论(0) 推荐(0)
摘要: 题目链接 class Solution { public ListNode rotateRight(ListNode head, int k) { if(head == null) return null; int len = 1; ListNode tail = head; while(tail. 阅读全文
posted @ 2022-02-07 01:25 蹇爱黄 阅读(25) 评论(0) 推荐(0)
摘要: 题目链接 这个是往里边填,并且是个规整的正方形矩阵 class Solution { public int[][] generateMatrix(int n) { int l = 0, r = n - 1, t = 0, b = n - 1; int[][] mat = new int[n][n]; 阅读全文
posted @ 2022-02-06 21:03 蹇爱黄 阅读(32) 评论(0) 推荐(0)
摘要: 题目链接 二刷发现已经忘光光了。。。。 class Solution { public List<Integer> spiralOrder(int[][] matrix) { List<Integer> ans = new ArrayList<>(); //二维数组长和宽 int n = matri 阅读全文
posted @ 2022-02-06 20:58 蹇爱黄 阅读(33) 评论(0) 推荐(0)
摘要: 题目链接 class Solution { public int maxSubArray(int[] nums) { //sum每轮暂时存值, int sum=0,res=nums[0]; for(int num:nums){ //sum为sum+下一个数组元素,与下一个数组元素之间的最大值 sum 阅读全文
posted @ 2022-02-06 20:35 蹇爱黄 阅读(20) 评论(0) 推荐(0)
摘要: 题目链接 回溯+递归 0ms class Solution { public List<List<Integer>> permute(int[] nums) { //1.初始化一个动态数组存储可能的数组 List<List<Integer>> res = new ArrayList<>(); //2 阅读全文
posted @ 2022-02-06 20:17 蹇爱黄 阅读(27) 评论(0) 推荐(0)
摘要: 题目链接 解题必看:0-9里边任意两数相乘,乘积最大也只有两位 num1的第i位(高位从0开始)和num2的第j位相乘的结果在乘积中的位置是[i+j, i+j+1] 例: 123 * 45, 123的第1位 2 和45的第0位 4 乘积 08 存放在结果的第[1, 2]位中 index: 0 1 2 阅读全文
posted @ 2022-02-06 17:41 蹇爱黄 阅读(37) 评论(0) 推荐(0)
摘要: 题目链接 class Solution { public int search(int[] nums, int target) { int len = nums.length; int l = 0,r = len - 1; while(l<=r){ //二分法 int mid = (l + r)/2 阅读全文
posted @ 2022-02-06 12:51 蹇爱黄 阅读(26) 评论(0) 推荐(0)
摘要: 题目链接 class Solution { public int removeDuplicates(int[] nums) { int fast=1,slow=0; while(fast<nums.length){ //如果快慢指针上的元素不相等就将该元素 if(nums[fast] != nums 阅读全文
posted @ 2022-02-06 02:47 蹇爱黄 阅读(27) 评论(0) 推荐(0)
摘要: 题目链接 0ms class Solution { public ListNode mergeTwoLists(ListNode list1, ListNode list2) { //如果某个list为空就直接返回零一list if(list1==null) return list2; if(lis 阅读全文
posted @ 2022-02-05 23:25 蹇爱黄 阅读(23) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 13 14 下一页