This commit is contained in:
Mrhongxing committed 2026-10-15 16:33:02 +08:00
1 parent d424ed1891
commit c03132a99d
8 files changed
+308

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
package com.hong.www;
public class Q12 {
public ListNode dfs(ListNode root){
ListNode next;
ListNode temp=null;
while (root!=null) {
next=root.next;
root.next=temp;
root=next;
temp=root;
}
return temp;
}
public ListNode reverseList(ListNode head) {
ListNode dummy = new ListNode(0);
return dfs(head);
}
}