
Queue
文章平均质量分 71
flyatcmu
这个作者很懒,什么都没留下…
展开
-
N-ary 题型总结
N-ary题型,最近问的比较多。总结一下。N-ary Tree Postorder TraversalN-ary Tree Preorder TraversalSerialize and Deserialize N-ary TreeMaximum Depth of N-ary TreeN-ary Tree Level Order Traversal原创 2020-08-05 13:34:34 · 824 阅读 · 0 评论 -
Serialize and Deserialize BST
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be...原创 2019-05-07 12:18:57 · 328 阅读 · 0 评论 -
Number of Matching Subsequences
Given stringSand adictionary of wordswords, find the number ofwords[i]that is a subsequence ofS.Example :Input: S = "abcde"words = ["a", "bb", "acd", "ace"]Output: 3Explanation: There are three words in words that are a subsequence of S: "a"...原创 2020-06-17 08:18:43 · 203 阅读 · 0 评论 -
RLE Iterator
Write an iterator that iterates through a run-length encoded sequence.The iterator is initialized byRLEIterator(int[] A), whereAis a run-length encoding of somesequence. More specifically,for all eveni,A[i]tells us the number of times that the n...原创 2020-06-15 13:17:13 · 204 阅读 · 0 评论 -
Read N Characters Given Read4 II - Call multiple times
The API:int read4(char *buf)reads 4 characters at a time from a file.The return value is the actual number of characters read. For example, it returns 3 if there is only 3 characters left in the原创 2014-12-12 13:14:20 · 3892 阅读 · 0 评论 -
Web Logger
Implement a web logger, which provide two methods:hit(timestamp), record a hit at given timestamp. get_hit_count_in_last_5_minutes(timestamp), get hit count in last 5 minutes.the two methods will ...原创 2020-01-21 11:46:33 · 389 阅读 · 0 评论 -
Moving Average from Data Stream
Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window.For example,MovingAverage m = new MovingAverage(3);m.next(1) = 1m.next(10) = ...原创 2016-06-29 12:48:53 · 386 阅读 · 0 评论 -
Implement Stack using Queues
Implement the following operations of a stack using queues.push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Get the top element. empty() -- Return ...原创 2016-07-14 05:42:31 · 298 阅读 · 0 评论 -
Number of Recent Calls
Write a class RecentCounter to count recent requests.It has only one method: ping(int t), where t represents some time in milliseconds.Return the number of pings that have been made from 3000 mill...原创 2018-12-25 08:56:41 · 256 阅读 · 0 评论