- 博客(23)
- 资源 (3)
- 收藏
- 关注
转载 leetcode Subsets II problem
Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain dupli
2013-05-26 22:06:32
767
转载 leetcode Unique Binary Search Trees II
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1
2013-05-07 22:52:18
939
转载 leetcode Subsets II
Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain d
2013-05-07 22:11:24
1450
转载 leetcode Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.O(n) solutionBinaryTree* sortedListToBST(ListNode *& list, int start, int end)
2013-05-07 22:04:46
722
转载 leetcode Sliding Window Maximum
A long array A[] is given to you. There is a sliding window of size w which is moving from the very left of the array to the very right. You can only see the wnumbers in the window. Each time the sl
2013-04-02 18:08:03
1578
原创 leetcode Populating Next Right Pointers in Each Node II
Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constan
2013-03-21 05:04:14
647
转载 Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Use min heap for every list. O(k*lgn)/** * Definition for singly-linked list. * public class
2013-03-17 05:59:41
1017
转载 a very interesting Microsoft interview problem
Given an array of 0s and 1s, find out: 1. all thesubarrays where number of 0s = number of 1s 2. max length subarrays where number of 0s = number of 1s The array is not sorted and can be
2013-03-07 01:42:51
678
原创 leetcode Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3Return 6.
2013-03-05 05:00:36
972
原创 leetcode Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1
2013-03-04 06:11:15
461
原创 leetcode Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.C++ is getting this problem more clear. you don't have random access to the list. so
2013-03-04 05:19:40
715
原创 leetcode integer to roman number conversion
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.This is also a google interview problem!I = 1 can be subtracted from 5, 10V =
2013-02-28 07:06:18
970
原创 leetcode Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists./** * Definition for singly-linked list. * public
2013-02-27 09:08:44
536
原创 leetcode Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".public class Solution { public String addBinary(String a, String b) {
2013-02-27 09:07:51
438
原创 leetcode Permutation Sequence
The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213"
2013-02-26 11:18:59
789
转载 leetcode Jump Game II
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal i
2013-02-25 07:06:31
793
原创 Multiply Strings(very long number)
Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative."123456789", "987654321""
2013-02-25 06:16:03
487
原创 leetcode First Missing Positive
Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses consta
2013-02-24 09:45:15
829
原创 reverse linkedlist in k group
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space.
2013-02-23 06:57:45
545
原创 leetcode Regular Expression Matching
Regular Expression MatchingImplement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching
2013-02-22 07:34:29
1051
原创 leetcode combination sum dp solution
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited
2013-02-19 23:25:42
4081
原创 毒酒问题binary search
有1000桶酒,其中1桶有毒。而一旦吃了,毒性会在1周后发作。现在我们用小老鼠做实验,要在1周内找出那桶毒酒,问最少需要多少老鼠老鼠按顺序排好每桶酒按照编号转换成二进制,给相应位置上是1的老鼠喝。最后按死掉的老鼠是哪几只,然后排成二进制,再转成十进制就是第几桶酒 1000转换成二进制是:1111101000, 共有十位,所以需10个第一次见到会觉得很难想,但其实这是一种
2013-02-17 03:53:10
918
原创 leetcode distinct subsequences dp solution
Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be n
2013-02-10 04:49:45
1049
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人