JAVA
文章平均质量分 93
南京小汤包
这个作者很懒,什么都没留下…
展开
-
小王的Leetcode刷题日记4
45、跳跃游戏II两步贪心class Solution { public int jump(int[] nums) { int curr_max = 0; int next_max = 0; int step = 0; for(int i=0;i<nums.length-1;i++){ if(i+nums[i] > next_max) next_max = i + nums[i];原创 2021-10-08 10:54:20 · 167 阅读 · 0 评论 -
小王的Leetcode刷题日记3
3、无重复字符的最长字串方法1、暴力求解逐个生成子字符串看它是否不含有重复的字符方法2、滑动窗口及优化从a-c都不重复,等到a重复的时候,左指针向右移动一位右指针向右移动一位双指针JAVA Code:class Solution { public int lengthOfLongestSubstring(String s) { HashSet<Character> set = new HashSet<>(); int right = -1;原创 2021-09-17 17:06:25 · 172 阅读 · 0 评论 -
小王的Leetcode刷题日记1
链表反转-迭代链表必须根据指针找到下一个元素public class ReverseList { static class ListNode{ int val; ListNode next; public ListNode (int val,ListNode next){ this.val = val; this.next = next; } } //迭代原创 2021-07-11 18:19:36 · 228 阅读 · 0 评论