LeetCode --- 1656. Design an Ordered Stream 解题报告

Posted 杨鑫newlfe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode --- 1656. Design an Ordered Stream 解题报告相关的知识,希望对你有一定的参考价值。

There is a stream of n (idKey, value) pairs arriving in an arbitrary order, where idKey is an integer between 1 and n and value is a string. No two pairs have the same id.

Design a stream that returns the values in increasing order of their IDs by returning a chunk (list) of values after each insertion. The concatenation of all the chunks should result in a list of the sorted values.

Implement the OrderedStream class:

  • OrderedStream(int n) Constructs the stream to take n values.
  • String[] insert(int idKey, String value) Inserts the pair (idKey, value) into the stream, then returns the largest possible chunk of currently inserted values that appear next in the order.

Example:

以上是关于LeetCode --- 1656. Design an Ordered Stream 解题报告的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode 1656. 设计有序流

算法leetcode|1656. 设计有序流(rust和go重拳出击)

算法leetcode|1656. 设计有序流(rust和go重拳出击)

LeetCode 641. 设计循环双端队列 / 1656. 设计有序流 / 302. 层数最深叶子节点的和

LeetCode 641. 设计循环双端队列 / 1656. 设计有序流 / 302. 层数最深叶子节点的和

leetcode 355 Design Twitte