摘要:
题目链接 这个是往里边填,并且是个规整的正方形矩阵 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
蹇爱黄
阅读(45)
评论(0)
推荐(0)
摘要:
题目链接 二刷发现已经忘光光了。。。。 class Solution { public List<Integer> spiralOrder(int[][] matrix) { List<Integer> ans = new ArrayList<>(); //二维数组长和宽 int n = matri 阅读全文
posted @ 2022-02-06 20:58
蹇爱黄
阅读(42)
评论(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
蹇爱黄
阅读(28)
评论(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
蹇爱黄
阅读(29)
评论(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
蹇爱黄
阅读(54)
评论(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
蹇爱黄
阅读(35)
评论(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
蹇爱黄
阅读(32)
评论(0)
推荐(0)

浙公网安备 33010602011771号