12 leileicaocao

尚未进行身份认证

我要认证

暂无相关简介

等级
TA的排名 3w+

DP:segment string

Segment a long string into a set of valid words using a dictionary. Return the maximum number  of the subwords.此题出自facebook面试题。方法一:套用矩阵连乘积模型。复杂度O(N^3)int segmentString(string str, set dict){ //

2013-09-03 18:42:45

递归将二叉树转换为双向链表

总体思路是递归,将二叉树转换为记录了头尾指针的双向链表,函数如下Void convertTreeToListHelp(TreeNode *root, TreeNode *&head, TreeNode *&tail){ Head = root; tail = root; If (!root) Return; TreeNode *pLeftHead = NULL; TreeNode

2013-09-03 16:17:11

LeetCode_FirstMissingPositive

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-07-22 09:34:24

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-06-30 20:55:27

LeetCode_Combination Sum II

Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the c

2013-06-30 12:22:33

LeetCode_Combination Sum

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-06-30 11:32:12

LeetCode_Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,

2013-06-30 10:28:54

LeetCode_Word Ladder

Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a timeEach intermediat

2013-06-29 20:17:01

LeetCode_Wildcard Matching

Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover t

2013-06-28 18:03:20

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-06-28 15:54:11

LeetCode_Permute II

Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1

2013-06-28 15:11:49

LeetCode_Permute

Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].void DFS(vect

2013-06-28 15:04:07

LeetCode_Rotate Image

You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?class Solution {public: void rotate(vector >

2013-06-28 14:51:21

LeetCode_Can Jump

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.Determine i

2013-06-28 11:59:15

LeetCode_Length Of Last Word

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is

2013-06-28 10:20:15

LeetCode_Unique Path II

Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the

2013-06-27 23:45:50

LeetCode_Unique Paths

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach th

2013-06-27 23:33:55

LeetCode_Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100"class Solution {public: string addBinary(string a, string b) { // Start

2013-06-27 23:17:04

LeetCode_Plus One

Given a number represented as an array of digits, plus one to the number.class Solution {public: vector plusOne(vector &arr) { // Start typing your C/C++ solution below // DO NO

2013-06-27 22:49:10

LeetCode_Sqrt

Implement int sqrt(int x).Compute and return the square root of x.class Solution {public: int sqrt(int x) { // Start typing your C/C++ solution below // DO NOT write i

2013-06-27 22:27:40

查看更多

勋章 我的勋章
    暂无奖章