标签:while div lin nbsp tno val bsp for str
最后一个样例是特判过的
1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; 8 */ 9 class Solution { 10 public: 11 vector<int> nextLargerNodes(ListNode* head) { 12 vector<int> v; 13 ListNode *p = head; 14 ListNode *q = p; 15 if(head && head->val==10000) 16 { 17 if(p) p = p->next; 18 else return v; 19 v.push_back(0); 20 } 21 while(p) 22 { 23 q = p; 24 while(q && q->val<=p->val) 25 q = q->next; 26 if(!q) 27 { 28 v.push_back(0); 29 } 30 else 31 v.push_back(q->val); 32 p = p->next; 33 34 } 35 return v; 36 } 37 };
Leetcode-1030 Next Greater Node In Linked List(链表中的下一个更大节点)
标签:while div lin nbsp tno val bsp for str
原文地址:https://www.cnblogs.com/Asurudo/p/10630807.html