/**

  • struct ListNode {
  •    int val;
    
  •    struct ListNode *next;
    
  •    ListNode(int x) :
    
  •          val(x), next(NULL) {
    
  •    }
    
  • }; */

class Solution { public: vector printListFromTailToHead(ListNode* head) { vector res; while(head) { res.push_back(head -> val); head = head -> next; } if(!res.empty())reverse(res.begin(), res.end()); return res; } };