摘要:
力扣题目链接 class Solution { public ListNode addTwoNumbers(ListNode l1, ListNode l2) { ListNode root = new ListNode(0); ListNode cursor = root; //保存进位值 int 阅读全文
posted @ 2022-02-04 19:15
蹇爱黄
阅读(26)
评论(0)
推荐(0)
摘要:
力扣题目链接 class Solution { public int numSubarrayProductLessThanK(int[] nums, int k) { if(k < 2) return 0; int i = 0,j = 0; int ans = 0; int x = 1; while 阅读全文
posted @ 2022-02-04 18:46
蹇爱黄
阅读(28)
评论(0)
推荐(0)
摘要:
力扣题目 解题思路: 双指针(有点滑动窗口的思想) 1.初始话最短数组的长度 min = Integer.MAX_VALUE 2.初始化一个数组的和 sum = 0; 3.定义变量(窗口的前后指针)i=0 j=0 j为快指针 4.开始遍历,当sum的值大于等于target时更新min 5.缩小窗口范 阅读全文
posted @ 2022-02-04 18:03
蹇爱黄
阅读(46)
评论(0)
推荐(0)
摘要:
力扣题目链接 6ms有点长也不知道咋优化 class Solution { public int threeSumClosest(int[] nums, int target) { int n = nums.length; //先排个序 Arrays.sort(nums); //记录第一个值 int 阅读全文
posted @ 2022-02-04 01:11
蹇爱黄
阅读(28)
评论(0)
推荐(0)
摘要:
力扣题目链接 第一种1ms class Solution { public String longestCommonPrefix(String[] strs) { //求出字符数组长度,方便后边遍历 int n = strs.length; if(n==0) return ""; //初始化返回值 阅读全文
posted @ 2022-02-04 00:09
蹇爱黄
阅读(37)
评论(0)
推荐(0)