0.8
This commit is contained in:
1 parent
d424ed1891
commit
c03132a99d
8 files changed
+308
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user