Reverse Linked List Time : O(n) Space : O(1) 123456789101112131415161718192021222324252627using namespace std;class LinkedList {public: int value; LinkedList *next; LinkedList(int value) { this->value = value; this->next = nullptr; }};LinkedList *reverseLinkedList(LinkedList *head) { LinkedList* dummy = new LinkedList(-1); LinkedList* tmp; while(head) { tmp = head->next; head->next = dummy->next; dummy->next = head; head = tmp; } return dummy->next;}