text: /**
   * Definition for singly-linked list.
   * struct ListNode {
   *     int val;
   *     ListNode *next;
   *     ListNode(int x) : val(x), next(NULL) {}
   * };
   */
  class Solution {
  public:
      ListNode* reverseList(ListNode* head) {
          ListNode* curr = head;
          ListNode* prev = NULL;
          ListNode* temp = NULL;
          while (curr != NULL) {
              temp = curr->next;
              curr->next = prev;
              prev = curr;
              curr = temp; // former curr->next
          }
          return prev; // the one whose next was NULL, or NULL if head was NULL
      }
  };
  