上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 36 下一页
摘要: 迭代 class Solution { public ListNode addTwoNumbers(ListNode l1, ListNode l2) { ListNode dummyHead = new ListNode(-1); ListNode head = dummyHead; ListNo 阅读全文
posted @ 2021-12-09 22:10 振袖秋枫问红叶 阅读(15) 评论(0) 推荐(0)
摘要: 迭代 class Solution { public ListNode oddEvenList(ListNode head) { if (head == null){ return head; } /** * 类似于《86. 分割链表》,奇数位置的节点不动,将偶数位置的节点全部放到最后面,原地完成 阅读全文
posted @ 2021-12-09 20:51 振袖秋枫问红叶 阅读(48) 评论(0) 推荐(0)
摘要: 迭代 class Solution { public ListNode partition(ListNode head, int x) { if (head == null){ return head; } ListNode dummyHead = new ListNode(-1); dummyHe 阅读全文
posted @ 2021-12-09 17:20 振袖秋枫问红叶 阅读(29) 评论(0) 推荐(0)
摘要: 迭代 class Solution { public ListNode reverseBetween(ListNode head, int left, int right) { if (left == right){ return head; } ListNode prev = null; List 阅读全文
posted @ 2021-12-09 14:28 振袖秋枫问红叶 阅读(47) 评论(0) 推荐(0)
摘要: 有序集合+滑动窗口 import java.util.TreeSet; class Solution { public boolean containsNearbyAlmostDuplicate(int[] nums, int k, int t) { /** * 有序集合+滑动窗口 * 因为满足ab 阅读全文
posted @ 2021-12-08 21:12 振袖秋枫问红叶 阅读(36) 评论(0) 推荐(0)
摘要: 集合 import java.util.HashSet; class Solution { public boolean containsDuplicate(int[] nums) { HashSet<Integer> set = new HashSet<>(); for (int i = 0; i 阅读全文
posted @ 2021-12-08 17:52 振袖秋枫问红叶 阅读(26) 评论(0) 推荐(0)
摘要: 暴力解法 class Solution { public int maxPoints(int[][] points) { int max = 1; /** * 暴力解法 * 直接将前两个点组成一条直线,然后比较后面的点看有没有在同一直线的 */ for (int i = 0; i < points. 阅读全文
posted @ 2021-12-08 17:09 振袖秋枫问红叶 阅读(37) 评论(0) 推荐(0)
摘要: 集合 import java.util.HashMap; class Solution { public int numberOfBoomerangs(int[][] points) { int count = 0; for (int i = 0; i < points.length; i++) { 阅读全文
posted @ 2021-12-08 14:13 振袖秋枫问红叶 阅读(38) 评论(0) 推荐(0)
摘要: 集合 import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; class Solution { public List<List<String>> gr 阅读全文
posted @ 2021-12-08 10:37 振袖秋枫问红叶 阅读(37) 评论(0) 推荐(0)
摘要: 哈希表 import java.util.HashMap; class Solution { public int fourSumCount(int[] nums1, int[] nums2, int[] nums3, int[] nums4) { /** * 将四重循环拆分成两个双重循环,然后类似 阅读全文
posted @ 2021-12-07 17:15 振袖秋枫问红叶 阅读(31) 评论(0) 推荐(0)
上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 36 下一页