leetcode
winuzz
这个作者很懒,什么都没留下…
展开
-
Leetcode | Lowest Common Ancestor of a Binary Search Tree
questionGiven a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined bet原创 2016-12-16 13:30:32 · 380 阅读 · 0 评论 -
Leetcode | Binary Tree Right Side View
question:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example: Given the following binary tree, 1原创 2016-12-19 20:07:26 · 352 阅读 · 0 评论 -
Leetcode | Count Complete Tree Nodes
questionGiven a complete binary tree, count the number of nodes.Definition of a complete binary tree from Wikipedia: In a complete binary tree every level, except possibly the last, is completely fill原创 2016-12-22 20:10:12 · 393 阅读 · 0 评论 -
LeetCode | Edit Distance
question:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a w原创 2017-01-01 21:06:09 · 387 阅读 · 0 评论 -
Leetcode | Basic Calculator
questionImplement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and emp原创 2016-12-09 21:15:21 · 305 阅读 · 0 评论 -
Leetcode | Binary Tree Inorder Traversal
question:Given a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree [1,null,2,3], 1\ 2/3return [1,3,2].explanation// 先将所有的左结点入栈 然后对每个出栈的结点进行判断 若该节点有右结点原创 2016-12-09 21:13:13 · 300 阅读 · 0 评论 -
Leetcode | Remove Duplicate Letters
questionGiven a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical原创 2016-12-09 20:48:36 · 405 阅读 · 0 评论 -
Leetcode | Verify Preorder Serialization of a Binary Tree
question: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, we record using a sentinel value such as原创 2016-12-07 16:48:06 · 338 阅读 · 0 评论 -
Leetcode | Mini Parser
questionGiven a nested list of integers represented as a string, implement a parser to deserialize it.Each element is either an integer, or a list – whose elements may also be integers or other lists.N原创 2016-12-07 16:24:28 · 350 阅读 · 0 评论 -
Leetcode | 132pattern
questionGiven 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 that takes a list of n numbers as input and che原创 2016-12-07 16:20:57 · 458 阅读 · 0 评论 -
Leetcode | Path Sum III
questionYou are given a binary tree in which each node contains an integer value.Find the number of paths that sum to a given value.The path does not need to start or end at the root or a leaf, but it原创 2016-12-13 19:20:57 · 441 阅读 · 0 评论 -
Leetcode | House Robber III
questionThe thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root, each house has one and only one parent house. After原创 2016-12-13 19:22:13 · 341 阅读 · 0 评论 -
LeetCode | Dungeon Game
question:The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initi原创 2016-12-29 17:11:33 · 342 阅读 · 0 评论