Skip to content

Commit ef8bb89

Browse files
committed
update at 2018-04-10
1 parent 7c1b544 commit ef8bb89

File tree

17 files changed

+54
-68
lines changed

17 files changed

+54
-68
lines changed

001-two-sum/two-sum.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
//
33
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
44
//
5-
//
65
// Example:
76
//
7+
//
88
// Given nums = [2, 7, 11, 15], target = 9,
99
//
1010
// Because nums[0] + nums[1] = 2 + 7 = 9,
1111
// return [0, 1].
1212
//
1313
//
14+
//  
15+
//
1416

1517

1618
/**

001-two-sum/two-sum.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
#
66
# You may assume that each input would have exactly one solution, and you may not use the same element twice.
77
#
8-
#
98
# Example:
109
#
10+
#
1111
# Given nums = [2, 7, 11, 15], target = 9,
1212
#
1313
# Because nums[0] + nums[1] = 2 + 7 = 9,
1414
# return [0, 1].
1515
#
1616
#
17+
#  
18+
#
1719

1820

1921
class Solution(object):

006-zigzag-conversion/zigzag-conversion.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
# -*- coding:utf-8 -*-
22

33

4+
# The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
45
#
5-
# The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
66
#
77
# P A H N
88
# A P L S I I G
99
# Y I R
1010
#
1111
#
12-
# And then read line by line: "PAHNAPLSIIGYIR"
12+
# And then read line by line: "PAHNAPLSIIGYIR"
1313
#
14+
#  
1415
#
1516
# Write the code that will take a string and make this conversion given a number of rows:
1617
#
18+
#
1719
# string convert(string text, int nRows);
1820
#
19-
# convert("PAYPALISHIRING", 3) should return "PAHNAPLSIIGYIR".
21+
# convert("PAYPALISHIRING", 3) should return "PAHNAPLSIIGYIR".
22+
#
23+
#  
2024
#
2125

2226

016-3sum-closest/3sum-closest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#
99
# The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).
1010
#
11+
#
1112

1213

1314
class Solution(object):

017-letter-combinations-of-a-phone-number/letter-combinations-of-a-phone-number.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33

44
# Given a digit string, return all possible letter combinations that the number could represent.
55
#
6-
#
7-
#
86
# A mapping of digit to letters (just like on the telephone buttons) is given below.
97
#
108
#
119
#
12-
# Input:Digit string "23"
13-
# Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
1410
#
11+
# Input:Digit string "23"
12+
# Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
1513
#
1614
#
1715
# Note:

024-swap-nodes-in-pairs/swap-nodes-in-pairs.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
# -*- coding:utf-8 -*-
22

33

4-
#
54
# Given a linked list, swap every two adjacent nodes and return its head.
65
#
7-
#
8-
#
96
# For example,
10-
# Given 1->2->3->4, you should return the list as 2->1->4->3.
11-
#
12-
#
7+
# Given 1->2->3->4, you should return the list as 2->1->4->3.
138
#
149
# Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed.
1510
#

067-add-binary/add-binary.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
# -*- coding:utf-8 -*-
22

33

4-
#
54
# Given two binary strings, return their sum (also a binary string).
65
#
7-
#
8-
#
96
# For example,
10-
# a = "11"
11-
# b = "1"
12-
# Return "100".
7+
# a = "11"
8+
# b = "1"
9+
# Return "100".
1310
#
1411

1512

071-simplify-path/simplify-path.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44
# Given an absolute path for a file (Unix-style), simplify it.
55
#
66
# For example,
7-
# path = "/home/", => "/home"
8-
# path = "/a/./b/../../c/", => "/c"
9-
#
7+
# path = "/home/", => "/home"
8+
# path = "/a/./b/../../c/", => "/c"
109
#
1110
# click to show corner cases.
1211
#
1312
# Corner Cases:
1413
#
14+
#  
15+
#
16+
#  
1517
#
1618
#
17-
# Did you consider the case where path = "/../"?
18-
# In this case, you should return "/".
19-
# Another corner case is the path might contain multiple slashes '/' together, such as "/home//foo/".
20-
# In this case, you should ignore redundant slashes and return "/home/foo".
19+
# Did you consider the case where path = "/../"?
20+
# In this case, you should return "/".
21+
# Another corner case is the path might contain multiple slashes '/' together, such as "/home//foo/".
22+
# In this case, you should ignore redundant slashes and return "/home/foo".
2123
#
2224
#
2325

080-remove-duplicates-from-sorted-array-ii/remove-duplicates-from-sorted-array-ii.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
# -*- coding:utf-8 -*-
22

33

4-
#
5-
# Follow up for "Remove Duplicates":
4+
# Follow up for "Remove Duplicates":
65
# What if duplicates are allowed at most twice?
76
#
8-
#
97
# For example,
108
# Given sorted array nums = [1,1,1,2,2,3],
119
#
12-
#
13-
# Your function should return length = 5, with the first five elements of nums being 1, 1, 2, 2 and 3. It doesn't matter what you leave beyond the new length.
10+
# Your function should return length = 5, with the first five elements of nums being 1, 1, 2, 2 and 3. It doesn't matter what you leave beyond the new length.
1411
#
1512

1613

083-remove-duplicates-from-sorted-list/remove-duplicates-from-sorted-list.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
# -*- coding:utf-8 -*-
22

33

4-
#
54
# Given a sorted linked list, delete all duplicates such that each element appear only once.
65
#
7-
#
86
# For example,
9-
# Given 1->1->2, return 1->2.
10-
# Given 1->1->2->3->3, return 1->2->3.
7+
# Given 1->1->2, return 1->2.
8+
# Given 1->1->2->3->3, return 1->2->3.
119
#
1210

1311

0 commit comments

Comments
 (0)