leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
0206.cpp (278B)
0 class Solution {
1 public:
2 ListNode *reverseList(ListNode *head) {
3 ListNode *p, *q, *r;
5 p = head, q = nullptr;
6 while (p) {
7 r = q;
8 q = p;
9 p = p->next;
10 q->next = r;
11 }
13 return q;
14 }
15 };