馬老師編譯原理
2022-10-25 22:09 作者:娜娜絡(luò)絡(luò) | 我要投稿
?public ListNode[] reversalList(ListNode head,ListNode tail) {
? ? ? ?ListNode[] result = ?{head,tail};
? ? ? ?if(head == null || head == tail) {
? ? ? ? ? ?
? ? ? ? ? ?return result;
? ? ? ?}
? ? ? ?ListNode temp = head;
? ? ? ?while(temp!=tail) {
? ? ? ? ? ?ListNode t = tail.next;
? ? ? ? ? ?tail.next = temp;
? ? ? ? ? ?ListNode n = temp.next;
? ? ? ? ? ?temp.next = t;
? ? ? ? ? ?temp = n;
? ? ? ?}
? ? ? ?return result;
? ?}
標簽: