![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
文章平均质量分 70
duffywan
这个作者很懒,什么都没留下…
展开
-
Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node's key.Th原创 2014-11-07 14:00:38 · 185 阅读 · 0 评论 -
Convert Sorted List to Binary Search Tree
Problem :Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.转载 2014-11-24 06:17:09 · 241 阅读 · 0 评论 -
Longest Increasing Subsequence Show Result My Submissions
Given a sequence of integers, find the longest increasing subsequence (LIS).You code should return the length of the LIS.ExampleFor [5, 4, 1, 2, 3], the LIS is [1, 2, 3], return 3For [4原创 2014-11-24 09:41:47 · 210 阅读 · 0 评论 -
Unique Permutations
Fair Unique PermutationsShow Result My Submissions16%AcceptedGiven a list of numbers with duplicate number in it. Find allunique permutations.ExampleFor numbers [1,2,2] t原创 2014-11-29 03:05:01 · 321 阅读 · 0 评论 -
4 Sum
Fair 4 SumShow Result My Submissions19%AcceptedGiven an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quad原创 2014-11-30 00:20:07 · 225 阅读 · 0 评论 -
Partition List
public class Solution { /** * @param head: The first node of linked list. * @param x: an integer * @return: a ListNode */ public ListNode partition(ListNode head, int x) {原创 2014-11-23 08:45:09 · 281 阅读 · 0 评论 -
Copy List with Random Pointer
Fair Copy List with Random PoiAcceptedA linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep cop原创 2014-11-24 04:02:17 · 218 阅读 · 0 评论 -
Unique Subsets
Given a list of numbers that may has duplicate numbers, return all possible subsetsNoteEach element in a subset must be in non-descending order.The ordering between two subsets is free.The原创 2014-11-29 02:22:17 · 354 阅读 · 0 评论 -
Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.public class Solution { public TreeNode sortedArrayToBST(int[] num) { if (num == null) return nu原创 2014-11-07 23:49:25 · 278 阅读 · 0 评论 -
Distinct Subsequences
Fair Distinct SubsequencesShow Result My Submissions25%AcceptedGiven a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string原创 2014-11-25 00:19:08 · 221 阅读 · 0 评论 -
Reverse Linked List II
Fair Reverse Linked List IIShow Result My Submissions27%AcceptedReverse a linked list from position m to n.NoteGiven m, n satisfy the following condition: 1 ≤ m ≤ n ≤ len原创 2014-11-23 06:48:04 · 188 阅读 · 0 评论 -
Reverse Linked List
Easy Reverse Linked ListShow Result My Submissions37%AcceptedReverse a linked list.ExampleFor linked list 1->2->3, the reversed linked list is 3->2->1Challenge Expa原创 2014-11-23 05:04:49 · 335 阅读 · 0 评论 -
Remove Duplicates from Sorted List II
Fair Remove Duplicates from Sorted List IIShow Result My Submissions28%AcceptedGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinct nu原创 2014-11-23 04:53:06 · 310 阅读 · 0 评论 -
Search Range in Binary Search Tree
Fair Search Range in Binary Search TreeShow Result My Submissions43%AcceptedGiven two values k1 and k2 (where k1 ExampleFor example, if k1 = 10 and k2 = 22, then your原创 2014-11-17 08:22:52 · 260 阅读 · 0 评论 -
Median of two Sorted Arrays
class Solution { /** * @param A: An integer array. * @param B: An integer array. * @return: a double whose format is *.5 or *.0 */ public double findMedianSortedArrays(int[原创 2014-11-16 02:26:41 · 392 阅读 · 0 评论 -
Lowest Common Ancestor
Fair Lowest Common AncestorMy Submissions32%AcceptedGiven the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes.The lowest common ances原创 2014-11-17 07:09:40 · 218 阅读 · 0 评论 -
Binary Tree Level Order Traversal
Fair Binary Tree Level Order TraversalShow Result My Submissions30%AcceptedGiven a binary tree, return the level order traversal of its nodes' values. (ie, from left to right原创 2014-11-17 09:46:26 · 216 阅读 · 0 评论 -
Binary Tree Level Order Traversal II
/** * Definition of TreeNode: * public class TreeNode { * public int val; * public TreeNode left, right; * public TreeNode(int val) { * this.val = val; * this.left =原创 2014-11-17 10:09:48 · 206 阅读 · 0 评论 -
Construct Binary Tree from Inorder and Postorder Traversal
Fair Construct Binary Tree from Inorder and Postorder TraversalShow Result My Submissions37%AcceptedGiven inorder and postorder traversal of a tree, construct the binary tree原创 2014-11-20 05:31:21 · 278 阅读 · 0 评论 -
Binary Tree Zigzag Level Order Traversal
Fair Binary Tree Zigzag Level Order TraversalShow Result My Submissions29%AcceptedGiven a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from原创 2014-11-17 10:38:04 · 296 阅读 · 0 评论 -
Construct Binary Tree from Preorder and Inorder Traversal
Fair Construct Binary Tree from Preorder and Inorder TraversalShow Result My Submissions35%AcceptedGiven preorder and inorder traversal of a tree, construct the binary tree.原创 2014-11-20 04:36:18 · 320 阅读 · 0 评论 -
Unique Binary Search Trees II
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.Idea: u原创 2014-11-06 03:24:44 · 205 阅读 · 0 评论 -
Interleaving String
Fair Interleaving StringMy Submissions54%AcceptedGiven three strings: s1, s2, s3, determine whether s3 is formed by the interleaving of s1 and s2.ExampleFor s1 = "aabcc" s2原创 2014-11-25 01:30:22 · 261 阅读 · 0 评论