摘要: 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 阅读全文
posted @ 2019-11-02 11:02 xuan_abc 阅读(119) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2019-11-01 11:43 xuan_abc 阅读(114) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2019-11-01 10:52 xuan_abc 阅读(167) 评论(0) 推荐(0)
摘要: You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following defin 阅读全文
posted @ 2019-10-29 11:38 xuan_abc 阅读(92) 评论(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 @ 2019-10-29 10:25 xuan_abc 阅读(97) 评论(0) 推荐(0)
摘要: Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For example, 阅读全文
posted @ 2019-10-28 10:57 xuan_abc 阅读(76) 评论(0) 推荐(0)
摘要: Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right pointers as synonymous to the previous and next pointers i 阅读全文
posted @ 2019-10-28 02:19 xuan_abc 阅读(103) 评论(0) 推荐(0)
摘要: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo 阅读全文
posted @ 2019-10-27 11:21 xuan_abc 阅读(131) 评论(0) 推荐(0)
摘要: Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look 阅读全文
posted @ 2019-10-23 10:54 xuan_abc 阅读(106) 评论(0) 推荐(0)
摘要: Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文
posted @ 2019-10-23 09:52 xuan_abc 阅读(115) 评论(0) 推荐(0)