We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent efe5ed3 commit d4bc43aCopy full SHA for d4bc43a
scripts/algorithms/N/Next Greater Node In Linked List/Next Greater Node In Linked List.cpp
@@ -1,3 +1,4 @@
1
+// Runtime: 1392 ms (Top 16.70%) | Memory: 41.2 MB (Top 71.62%)
2
class Solution {
3
public:
4
vector<int> nextLargerNodes(ListNode* head) {
@@ -7,15 +8,15 @@ class Solution {
7
8
ans.push_back(0);
9
return ans;
10
}
-
11
+
12
while(curr != NULL){
13
ListNode* next = curr->next;
14
while(next != NULL){
15
if(next->val > curr->val){
16
ans.push_back(next->val);
17
break;
- }
18
- next = next->next;
+ }
19
+ next = next->next;
20
21
if(next == NULL){
22
@@ -24,4 +25,4 @@ class Solution {
24
25
26
27
-};
28
+};
0 commit comments