
interview questions
文章平均质量分 68
zyfo2
这个作者很懒,什么都没留下…
展开
-
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 · 1054 阅读 · 0 评论 -
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 · 792 阅读 · 0 评论 -
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 · 463 阅读 · 0 评论 -
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 · 1019 阅读 · 0 评论 -
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 · 1582 阅读 · 0 评论 -
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 · 717 阅读 · 0 评论 -
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 · 4085 阅读 · 0 评论 -
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 · 723 阅读 · 0 评论 -
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 · 1455 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 975 阅读 · 2 评论 -
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 · 538 阅读 · 0 评论 -
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 · 441 阅读 · 0 评论 -
毒酒问题binary search
有1000桶酒,其中1桶有毒。而一旦吃了,毒性会在1周后发作。现在我们用小老鼠做实验,要在1周内找出那桶毒酒,问最少需要多少老鼠老鼠按顺序排好每桶酒按照编号转换成二进制,给相应位置上是1的老鼠喝。最后按死掉的老鼠是哪几只,然后排成二进制,再转成十进制就是第几桶酒 1000转换成二进制是:1111101000, 共有十位,所以需10个第一次见到会觉得很难想,但其实这是一种原创 2013-02-17 03:53:10 · 920 阅读 · 0 评论 -
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 · 973 阅读 · 0 评论 -
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 · 680 阅读 · 0 评论 -
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 · 1056 阅读 · 0 评论 -
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 · 548 阅读 · 0 评论 -
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 · 833 阅读 · 0 评论 -
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 · 495 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论