手记

剑指offer

         

package jianzhiOffer;/** * 输入一个链表,反转链表后,输出链表的所有元素。 * @author user * 思路:使链表的所有节点都指向上一个结点 */public class ch15 {	public ListNode ReverseList(ListNode head) {		ListNode pre = null;		ListNode next = null;		while(head != null) {			next = head.next;			head.next = pre;			pre = head;			head = next;		}		return pre;    }}


0人推荐
随时随地看视频
慕课网APP