Skip to content

Commit

Permalink
更新helper助手和README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
aQua authored and aQua committed Aug 20, 2017
1 parent a7ce87c commit 6dcb4ea
Show file tree
Hide file tree
Showing 338 changed files with 6,802 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Algorithms/0044.wildcard-matching/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

## 题目

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 the entire input string (not partial).

The function prototype should be:
bool isMatch(const char *s, const char *p)

Some examples:
isMatch("aa","a") → false
isMatch("aa","aa") → true
isMatch("aaa","aa") → false
isMatch("aa", "*") → true
isMatch("aa", "a*") → true
isMatch("ab", "?*") → true
isMatch("aab", "c*a*b") → false


## 解题思路

Expand Down
17 changes: 17 additions & 0 deletions Algorithms/0054.spiral-matrix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

## 题目

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 ]
]


You should return [1,2,3,6,9,8,7,4,5].


## 解题思路

Expand Down
18 changes: 18 additions & 0 deletions Algorithms/0055.jump-game/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

## 题目

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 if you are able to reach the last index.



For example:
A = [2,3,1,1,4], return true.


A = [3,2,1,0,4], return false.


## 解题思路

Expand Down
8 changes: 8 additions & 0 deletions Algorithms/0056.merge-intervals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## 题目

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].


## 解题思路

Expand Down
18 changes: 18 additions & 0 deletions Algorithms/0057.insert-interval/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

## 题目

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 times.


Example 1:
Given intervals [1,3],[6,9], insert and merge [2,5] in as [1,5],[6,9].



Example 2:
Given [1,2],[3,5],[6,7],[8,10],[12,16], insert and merge [4,9] in as [1,2],[3,10],[12,16].



This is because the new interval [4,9] overlaps with [3,5],[6,7],[8,10].


## 解题思路

Expand Down
12 changes: 12 additions & 0 deletions Algorithms/0058.length-of-last-word/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

## 题目

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 defined as a character sequence consists of non-space characters only.


For example,
Given s = "Hello World",
return 5.


## 解题思路

Expand Down
14 changes: 14 additions & 0 deletions Algorithms/0059.spiral-matrix-ii/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

## 题目

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, 4 ],
[ 7, 6, 5 ]
]


## 解题思路

Expand Down
18 changes: 18 additions & 0 deletions Algorithms/0060.permutation-sequence/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

## 题目

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"
"231"
"312"
"321"



Given n and k, return the kth permutation sequence.

Note: Given n will be between 1 and 9 inclusive.


## 解题思路

Expand Down
6 changes: 6 additions & 0 deletions Algorithms/0061.rotate-list/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## 题目

Given a list, rotate the list to the right by k places, where k is non-negative.

For example:
Given 1->2->3->4->5->NULL and k = 2,
return 4->5->1->2->3->NULL.


## 解题思路

Expand Down
13 changes: 13 additions & 0 deletions Algorithms/0062.unique-paths/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

## 题目

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 the bottom-right corner of the grid (marked 'Finish' in the diagram below).

How many possible unique paths are there?



Above is a 3 x 7 grid. How many possible unique paths are there?


Note: m and n will be at most 100.


## 解题思路

Expand Down
18 changes: 18 additions & 0 deletions Algorithms/0063.unique-paths-ii/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

## 题目

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 grid.

For example,
There is one obstacle in the middle of a 3x3 grid as illustrated below.
[
[0,0,0],
[0,1,0],
[0,0,0]
]

The total number of unique paths is 2.

Note: m and n will be at most 100.


## 解题思路

Expand Down
4 changes: 4 additions & 0 deletions Algorithms/0064.minimum-path-sum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 题目

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.

Note: You can only move either down or right at any point in time.


## 解题思路

Expand Down
19 changes: 19 additions & 0 deletions Algorithms/0065.valid-number/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

## 题目

Validate if a given string is numeric.


Some examples:
"0" => true
" 0.1 " => true
"abc" => false
"1 a" => false
"2e10" => true


Note: It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implementing one.



Update (2015-02-10):
The signature of the C++ function had been updated. If you still see your function signature accepts a const char * argument, please click the reload button to reset your code definition.


## 解题思路

Expand Down
11 changes: 11 additions & 0 deletions Algorithms/0067.add-binary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

## 题目

Given two binary strings, return their sum (also a binary string).



For example,
a = "11"
b = "1"
Return "100".


## 解题思路

Expand Down
47 changes: 47 additions & 0 deletions Algorithms/0068.text-justification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,53 @@

## 题目

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; that is, pack as many words as you can in each line. Pad extra spaces ' ' when necessary so that each line has exactly L characters.



Extra spaces between words should be distributed as evenly as possible. If the number of spaces on a line do not divide evenly between words, the empty slots on the left will be assigned more spaces than the slots on the right.



For the last line of text, it should be left justified and no extra space is inserted between words.



For example,
words: ["This", "is", "an", "example", "of", "text", "justification."]
L: 16.



Return the formatted lines as:
[
"This is an",
"example of text",
"justification. "
]




Note: Each word is guaranteed not to exceed L in length.



click to show corner cases.

Corner Cases:


A line other than the last line might contain only one word. What should you do in this case?
In this case, that line should be left-justified.



## 解题思路

Expand Down
4 changes: 4 additions & 0 deletions Algorithms/0069.sqrtx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 题目

Implement int sqrt(int x).

Compute and return the square root of x.


## 解题思路

Expand Down
8 changes: 8 additions & 0 deletions Algorithms/0070.climbing-stairs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## 题目

You are climbing a stair case. It takes n steps to reach to the top.

Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?


Note: Given n will be a positive integer.


## 解题思路

Expand Down
Loading

0 comments on commit 6dcb4ea

Please sign in to comment.