随笔分类 - leetcode_stack
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another e
阅读全文
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Remov
阅读全文
摘要:One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node,
阅读全文
摘要:Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note: The l
阅读全文
摘要:Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence ai, aj, ak such that i < j < k and ai < ak < aj. Design an algorithm th
阅读全文
摘要:You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1'
阅读全文
摘要:Given a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The
阅读全文
摘要: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
阅读全文
摘要:Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() -- Removes the element from in front
阅读全文
摘要: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. to
阅读全文
摘要:Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is b
阅读全文
摘要:Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tree [1,null,2,3], return [1,3,2]. 题目含义:用中序遍历树并输出
阅读全文
摘要:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree [3
阅读全文
摘要:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and
阅读全文
摘要:Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [1,2,3]. Note: Recursive solu
阅读全文
摘要: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 n
阅读全文
摘要:Design a data structure that supports all following operations in average O(1) time. 设计一个数据结构,使得插入、删除,随机获取一个元素的时间复杂度都是O(1)
阅读全文