随笔分类 -  iterator

900. RLE Iterator
摘要:900. RLE Iterator https://leetcode.com/problems/rle-iterator/solution/ 阅读全文

posted @ 2018-11-08 16:04 猪猪🐷

604. Design Compressed String Iterator
摘要:Design and implement a data structure for a compressed string iterator. It should support the following operations: next and hasNext. The given compressed string will be in the form of each letter fo... 阅读全文

posted @ 2018-11-06 08:16 猪猪🐷

173. Binary Search Tree Iterator
摘要:Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the next smallest number in the BST. Note: next() and ... 阅读全文

posted @ 2018-11-06 08:15 猪猪🐷

251. Flatten 2D Vector
摘要:251. Flatten 2D Vector Implement an iterator to flatten a 2d vector. Example: Input: 2d vector = [ [1,2], [3], [4,5,6] ] Output: [1,2,3,4,5,6] Explanation: By calling next repeatedly until has... 阅读全文

posted @ 2018-11-06 08:15 猪猪🐷

preorder iterator of binary tree
摘要:实现 next(), hasNext() . Follow up: 实现 remove, remove 要求删除next()last visited node and its subtree. 阅读全文

posted @ 2018-08-11 03:19 猪猪🐷

k sorted list iterator.
摘要:k sorted list iterator. 写个被多次 call 的 getNext()。没要求用 iterator, 于是 heap 秒了。面试官表示很满意。 阅读全文

posted @ 2018-08-11 03:18 猪猪🐷

merge sorted iterator
摘要:merge sorted iterator 这个小班 讲过, 小班文档上应该有 阅读全文

posted @ 2018-08-11 03:17 猪猪🐷

281 Zigzag Iterator
摘要:Given two 1d vectors, implement an iterator to return their elements alternately. Example: Follow up: What if you are given k 1d vectors? How well can 阅读全文

posted @ 2018-08-10 16:31 猪猪🐷

Iterator 1
摘要:Iterator 1 Concat iterator 14 Cyclic iterator 22.28 Filter iterator (positive) Predicate 32.10 Sequence iterator Iterator of iterator Iterator inner Iterator outer 55.12 Even ind... 阅读全文

posted @ 2018-08-09 18:05 猪猪🐷

Iterator 2
摘要:Iterator 2 Flatten 2d vector 21.13 51.52 Flatten nested list 54.36 1.15 peek iterator Merge list of list , using peek iterator 1.27 Bst 1.49 ======================= // flatten 2d... 阅读全文

posted @ 2018-08-09 18:03 猪猪🐷

iterator
摘要:You can call next() without calling hasNext(), You can call hasNext() multiple times without calling next() even once 阅读全文

posted @ 2018-08-09 18:02 猪猪🐷

341. Flatten Nested List Iterator
摘要:Given a nested list of integers, implement an iterator to flatten it. Each element is either an integer, or a list -- whose elements may also be integ 阅读全文

posted @ 2018-08-09 18:00 猪猪🐷

284. Peeking Iterator
摘要:Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation -- it e 阅读全文

posted @ 2018-08-09 17:59 猪猪🐷

two bst iterator
摘要:bst iterator 阅读全文

posted @ 2018-08-09 17:58 猪猪🐷

导航