aboutsummaryrefslogtreecommitdiff
path: root/flatten_nested_iterator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'flatten_nested_iterator.cpp')
-rw-r--r--flatten_nested_iterator.cpp33
1 files changed, 0 insertions, 33 deletions
diff --git a/flatten_nested_iterator.cpp b/flatten_nested_iterator.cpp
deleted file mode 100644
index 4a6f93c..0000000
--- a/flatten_nested_iterator.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "leetcode.h"
-
-class NestedIterator {
-public:
- NestedIterator(vector<NestedInteger> &nestedList) {
- int n = nestedList.size();
- for (int i = n - 1; i >= 0; --i)
- nodes.push(nestedList[i]);
- }
- int next() {
- int ans = nodes.top().getInteger();
- nodes.pop();
- return ans;
- }
- bool hasNext() {
- while (!nodes.empty()) {
- NestedInteger curr = nodes.top();
- if (curr.isInteger())
- return true;
- nodes.pop();
- vector<NestedInteger> &adj = curr.getList();
- int n = adj.size();
- for (int i = n - 1; i >= 0; --i)
- nodes.push(adj[i]);
- }
- return false;
- }
-
-private:
- stack<NestedInteger> nodes;
-};
-
-int main() {}