自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(157)
  • 收藏
  • 关注

原创 Interleaving String

Q:Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbac

2014-12-13 14:13:34 230

原创 Edit Distance

Q: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

2014-12-12 09:07:38 265

原创 Merge Intervals

Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].Solution:Using insert interval:/** * Definiti

2014-12-11 17:13:27 311

原创 Insert Interval

Q:Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start tim

2014-12-11 16:01:06 234

原创 Scramble String

Q:Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great /

2014-12-11 01:02:44 389

原创 Trapping Rain Water

Q: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,

2014-12-06 22:11:58 216

原创 Maximal Rectangle

Q:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.Solution:An extension of Largest Rectangle in Histogram problem. Maintain

2014-12-06 21:20:10 214

原创 Minimum Window Substring

Q:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window

2014-12-06 15:36:34 284

原创 Find Peak Element

Q:A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple pe

2014-12-06 15:35:29 238

原创 Wildcard Matching

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

2014-12-05 17:18:34 151

原创 Text Justification

Q:Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified.You should pack your words in a greedy approach

2014-12-03 13:51:04 204

原创 Largest Rectangle in Histogram

Q:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where

2014-11-30 20:06:19 211

原创 Spiral Matrix II

Q:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9,

2014-11-30 19:15:04 205

原创 Spiral Matrix

Q:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9

2014-11-30 18:21:00 196

原创 Substring with Concatenation of All Words

Q:You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and

2014-11-30 16:47:19 250

原创 Decode Ways

Q:A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the to

2014-11-29 15:59:07 209

原创 Valid Number

Q:Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be

2014-11-29 13:26:19 259

原创 Longest Palindromic Substring

Q:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.Solution

2014-11-28 23:57:39 217

原创 Longest Substring Without Repeating Characters

Q:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3

2014-11-28 13:29:43 238

原创 Intersection of Two Linked Lists

Q:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘

2014-11-28 10:38:01 247

原创 Triangle

Q:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,

2014-11-28 09:44:03 174

原创 Regular Expression Matching

Q:mplement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire i

2014-11-27 17:16:27 219

原创 Multiply Strings

Q: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.Solution:public class Solut

2014-11-27 13:08:34 182

原创 First Missing Positive

Q: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

2014-11-26 14:22:25 192

原创 Surrounded Regions

Q:Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X X X

2014-11-26 11:38:00 180

原创 Evaluate Reverse Polish Notation

Q:Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2

2014-11-26 09:09:47 266

原创 Combination Sum II

Q: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

2014-11-26 08:44:46 160

原创 Palindrome Partitioning II

Q:Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = "aab",Retu

2014-11-25 21:14:59 171

原创 Palindrome Partitioning

Q:Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [

2014-11-25 11:35:24 161

原创 Unique Paths II

Q: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

2014-11-24 11:27:31 192

原创 Word Ladder II

Q:Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:Only one letter can be changed at a timeEach intermediate word

2014-11-20 12:40:42 205

原创 LRU Cache

Q:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the

2014-11-20 10:31:58 217

原创 Reverse Words in a String

Q:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Clarification:What constitutes a word?A sequence o

2014-11-20 08:22:31 195

原创 Find Minimum in Rotated Sorted Array II

Q:Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Suppose a sorted array is rotated at some

2014-11-20 08:01:15 178

原创 Find Minimum in Rotated Sorted Array

Q:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate ex

2014-11-20 07:48:10 163

原创 Recover Binary Search Tree

Q:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you dev

2014-11-20 03:28:21 209

原创 Unique Binary Search Trees II

Q: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

2014-11-19 23:48:42 174

原创 Flatten Binary Tree to Linked Li

Q: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:

2014-11-19 17:18:04 181

原创 Word Break II

Q:Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, give

2014-11-19 15:55:35 226

原创 Max Points on a Line

Q:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.Solution:/** * Definition for a point. * class Point { * int x; * int y; *

2014-11-19 07:27:37 159

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除