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); } }