feat: 2025-10-29打卡

This commit is contained in:
wu xiangkai
2025-10-29 10:18:53 +08:00
parent 2fa03ec244
commit 7a33a111b1
3 changed files with 124 additions and 7 deletions

View File

@@ -26,15 +26,18 @@ class Solution {
public ListNode reverseBetween(ListNode head, int left, int right) {
ListNode dummy = new ListNode(0);
dummy.next = head;
ListNode prev = dummy;
for(int i = 0; i< left-1; i++) {
ListNode prev, frm;
prev = frm = dummy;
for(int i = 0; i<left-1; i++) {
prev = prev.next;
}
ListNode cur = prev.next;
ListNode tail = cur, tmp;
for(int i = 0; i < right-left; i++) {
cur = tail.next;
tail.next = cur.next;
for(int i = 0; i < left; i++) {
frm = frm.next;
}
ListNode cur;
for(int i = 0; i<right-left; i++) {
cur = frm.next;
frm.next = cur.next;
cur.next = prev.next;
prev.next = cur;
}