文章 2023-01-05 来自:开发者社区

LeetCode 341. Flatten Nested List Iterator

DescriptionGiven 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 integers or other lists.Example 1:Input: [[1....

LeetCode 341. Flatten Nested List Iterator
文章 2023-01-05 来自:开发者社区

LeetCode 284. Peeking Iterator

DescriptionGiven an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation -- it essentially peek() at the element that ....

LeetCode 284. Peeking Iterator
文章 2022-04-15 来自:开发者社区

[LeetCode]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. Not...

文章 2022-02-16 来自:开发者社区

[LeetCode] 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:&nb...

文章 2022-02-16 来自:开发者社区

[LeetCode] Peeking Iterator 顶端迭代器

Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation -- it essentially peek() at the ...

文章 2022-02-16 来自:开发者社区

[LeetCode] Zigzag Iterator 之字形迭代器

Given two 1d vectors, implement an iterator to return their elements alternately. For example, given two 1d vectors: v1 = [1, 2] v2 = [3, 4, 5, 6] By calling next repeatedly until hasNe...

文章 2022-02-16 来自:开发者社区

[LeetCode] 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 integers or other lists. Example 1: Given the list ...

文章 2022-02-16 来自:开发者社区

[LeetCode] Binary Search Tree Iterator

The key to this problem is to store the values in a stack. In the constructor and next, we add all the next smallest nodes into the stack. The following code should be obvious after you run it on som....

文章 2022-02-16 来自:开发者社区

[LeetCode] Peeking Iterator

An interesting problem about iterators. This post shares a very nice solution, which is rewritten below, with minor simplifications. // Below is the interface for Iterator, which is already defined .....

文章 2022-02-16 来自:开发者社区

[LeetCode] Zigzag Iterator

Problem Description: Given two 1d vectors, implement an iterator to return their elements alternately. For example, given two 1d vectors: v1 = [1, 2] v2 = [3, 4, 5, 6]  By calling next ...

本页面内关键词为智能算法引擎基于机器学习所生成,如有任何问题,可在页面下方点击"联系我们"与我们沟通。

算法编程

开发者社区在线编程频道官方技术圈。包含算法资源更新,周赛动态,每日一题互动。

+关注