JAVA 反转链表
作者:互联网
class Solution { ListNode p1 ; public ListNode reverseList(ListNode head) { ListNode p = head; while(p!=null){ addFirst(p.val); p = p.next; } return p1; } void addFirst(int a){ ListNode renode=new ListNode(a); if(p1!=null){ renode.next = p1; } p1 = renode; } }
标签:head,p1,ListNode,反转,renode,next,链表,addFirst,JAVA 来源: https://www.cnblogs.com/tingtin/p/15706255.html