1. 链表

链表逆转

 1 class Solution {
 2 public:
 3     ListNode* reverseList(ListNode* head) {
 4         ListNode* prev = NULL;
 5         while (head != NULL) {
 6             ListNode* next = head->next;
 7             head->next = prev;
 8             prev = head;
 9             head = next;
10         }
11         return prev;
12     }
13 };
View Code

相关文章:

  • 2021-05-22
  • 2021-11-21
  • 2021-10-20
  • 2021-12-19
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
猜你喜欢
  • 2022-12-23
  • 2021-10-07
  • 2021-10-08
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2022-01-16
相关资源
相似解决方案