…
/
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode next;
* ListNode(int x) : val(x), next(NULL) {}
* };
/
class Solution {
public:
vector[HTML_REMOVED] printListReversingly(ListNode* head) {
vector[HTML_REMOVED] res;
while (head) {
res.push_back(head->val);
head = head->next;
}
return vector[HTML_REMOVED](res.rbegin(), res.rend());
}
};
…