From 9639d043e86d756af53a79e43452cd3109cd1b3c Mon Sep 17 00:00:00 2001 From: wu xiangkai Date: Fri, 24 Oct 2025 11:28:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=202025-10-24=E6=89=93=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 160.intersection-of-two-linked-lists.java | 59 ++++++++++++++++++++++ 2.add-two-numbers.java | 56 ++++++++++++++++++++ 203.remove-linked-list-elements.java | 38 ++++++++++++++ 206.reverse-linked-list.java | 31 ++++++++++++ 234.palindrome-linked-list.java | 54 ++++++++++++++++++++ 766.toeplitz-matrix.java | 38 ++++++++++++++ 83.remove-duplicates-from-sorted-list.java | 36 +++++++++++++ 908.smallest-range-i.java | 26 ++++++++++ 8 files changed, 338 insertions(+) create mode 100644 160.intersection-of-two-linked-lists.java create mode 100644 2.add-two-numbers.java create mode 100644 203.remove-linked-list-elements.java create mode 100644 206.reverse-linked-list.java create mode 100644 234.palindrome-linked-list.java create mode 100644 766.toeplitz-matrix.java create mode 100644 83.remove-duplicates-from-sorted-list.java create mode 100644 908.smallest-range-i.java diff --git a/160.intersection-of-two-linked-lists.java b/160.intersection-of-two-linked-lists.java new file mode 100644 index 0000000..2754012 --- /dev/null +++ b/160.intersection-of-two-linked-lists.java @@ -0,0 +1,59 @@ +/* + * @lc app=leetcode id=160 lang=java + * + * [160] Intersection of Two Linked Lists + */ + +// @lc code=start +/** + * Definition for singly-linked list. + * public class ListNode { + * int val; + * ListNode next; + * ListNode(int x) { + * val = x; + * next = null; + * } + * } + */ +public class Solution { + public ListNode getIntersectionNode(ListNode headA, ListNode headB) { + if(headA == null || headB == null) { + return null; + } + int la = len(headA), lb = len(headB); + ListNode cura = headA, curb = headB; + if(la < lb) { + // move curB + for(int i=0; i max) { + max = nums[i]; + } + } + return max - min > 2 * k ? max - min - 2 * k : 0; + } +} +// @lc code=end +