標籤:: Stack

0

Verify Preorder Serialization of a Binary Tree

Verify Preorder Serialization of a Binary TreeOne 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, we

0

Evaluate Reverse Polish Notation

Evaluate Reverse Polish NotationEvaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. For ex

0

Binary Tree Preorder Traversal

Binary Tree Preorder TraversalGiven a binary tree, return the preorder traversal of its nodes’ values. For example:Given binary tree {1,#,2,3}, 123451 \ 2 /3 return [1,2,3]. Note: Recursive solution

0

Binary Tree Zigzag Level Order Traversal

Binary Tree Zigzag Level Order TraversalGiven 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 alternate

0

Binary Tree Inorder Traversal

Binary Tree Inorder TraversalGiven a binary tree, return the inorder traversal of its nodes’ values. For example:Given binary tree [1,null,2,3], 123451 \ 2 /3 return [1,3,2]. Note: Recursive solutio

0

Simplify Path

Simplify PathGiven an absolute path for a file (Unix-style), simplify it. For example:12path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c" 提

0

Next Greater Element I

Next Greater Element IYou 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’s elements in the correspon

0

Implement Queue using Stacks

Implement Queue using StacksImplement 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 of queue. peek() – Ge

0

Implement Stack using Queues

Implement Stack using QueuesImplement 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 elem

0

Min Stack

Min StackDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top()

0

Valid Parentheses

Valid ParenthesesGiven a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, determine if the input string is valid. The brackets must close in the correct order, “()” and “()[]{}”