Home Day 5 Linked List | Striver 180 | takeUforward
Post
Cancel

Day 5 Linked List | Striver 180 | takeUforward

Problem 1: Reverse a LinkedList

1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Solution {
public:
    ListNode* reverseList(ListNode* next) {
        ListNode* prev = NULL;
        while(next != NULL)
        {
            ListNode* curr = next;
            next = next->next;
            curr->next = prev;
            prev = curr;
        }
        return prev;
    }
};
This post is licensed under CC BY 4.0 by the author.

Day 21 Binary Search Tree II | Striver 180 | takeUforward

Day 8 Greedy | Striver 180 | takeUforward