随笔分类 -  Stack & Queue

摘要:You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward i 阅读全文
posted @ 2021-06-21 09:44 北叶青藤 阅读(37) 评论(0) 推荐(0)
摘要:Design a stack which supports the following operations. Implement the CustomStack class: CustomStack(int maxSize) Initializes the object with maxSize  阅读全文
posted @ 2021-04-27 23:00 北叶青藤 阅读(110) 评论(0) 推荐(0)
摘要:Problem description: Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the 阅读全文
posted @ 2020-12-16 07:47 北叶青藤 阅读(102) 评论(0) 推荐(0)
摘要:Design your implementation of the circular double-ended queue (deque). Your implementation should support following operations: MyCircularDeque(k): Co 阅读全文
posted @ 2019-08-11 09:46 北叶青藤 阅读(224) 评论(0) 推荐(0)
摘要:Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (F 阅读全文
posted @ 2019-08-11 09:02 北叶青藤 阅读(225) 评论(0) 推荐(0)
摘要:Infix : An expression is called the Infix expression if the operator appears in between the operands in the expression. Simply of the form (operand1 o 阅读全文
posted @ 2019-08-08 00:35 北叶青藤 阅读(457) 评论(0) 推荐(0)
摘要:Infix expression: The expression of the form a op b. When an operator is in-between every pair of operands.Postfix expression: The expression of the f 阅读全文
posted @ 2019-08-08 00:24 北叶青藤 阅读(288) 评论(0) 推荐(0)
摘要:Infix : An expression is called the Infix expression if the operator appears in between the operands in the expression. Simply of the form (operand1 o 阅读全文
posted @ 2019-08-08 00:14 北叶青藤 阅读(384) 评论(0) 推荐(0)
摘要:Postfix to Prefix Conversion Postfix: An expression is called the postfix expression if the operator appears in the expression after the operands. Sim 阅读全文
posted @ 2019-08-08 00:07 北叶青藤 阅读(466) 评论(0) 推荐(0)
摘要:Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warme 阅读全文
posted @ 2019-08-01 13:56 北叶青藤 阅读(186) 评论(0) 推荐(0)
摘要:Design a hit counter which counts the number of hits received in the past 5 minutes. Each function accepts a timestamp parameter (in seconds granularity) and you may assume that calls are being made ... 阅读全文
posted @ 2019-07-26 13:53 北叶青藤 阅读(197) 评论(0) 推荐(0)
摘要:Example : Infix : (A+B) * (C-D) ) Postfix: AB+CD-* 算法: 1. Scan the infix expression from left to right. 2. If the scanned character is an operand, app 阅读全文
posted @ 2019-07-22 13:40 北叶青藤 阅读(356) 评论(0) 推荐(0)
摘要:Implement FreqStack, a class which simulates the operation of a stack-like data structure. FreqStack has two functions: push(int x), which pushes an i 阅读全文
posted @ 2019-07-19 15:12 北叶青藤 阅读(254) 评论(0) 推荐(0)
摘要:Given a string representing arbitrarily nested ternary expressions, calculate the result of the expression. You can always assume that the given expre 阅读全文
posted @ 2017-01-03 10:36 北叶青藤 阅读(220) 评论(0) 推荐(0)
摘要: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 Mo 阅读全文
posted @ 2017-01-03 06:49 北叶青藤 阅读(131) 评论(0) 推荐(0)
摘要:Implement Queue by Two Stacks Implement Queue by Two Stacks Implement Queue by Two Stacks Implement the following operations of a queue using stacks. 阅读全文
posted @ 2016-07-19 05:41 北叶青藤 阅读(314) 评论(0) 推荐(0)
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another e 阅读全文
posted @ 2016-07-17 20:10 北叶青藤 阅读(179) 评论(0) 推荐(0)
摘要:Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. Example The b 阅读全文
posted @ 2016-07-13 11:03 北叶青藤 阅读(260) 评论(0) 推荐(0)
摘要:Implement a stack with min() function, which will return the smallest number in the stack. It should support push, pop and min operation all in O(1) c 阅读全文
posted @ 2016-07-09 07:59 北叶青藤 阅读(188) 评论(0) 推荐(0)