10000 update at 2018-09-27 · liusoon/leetcode@f104647 · GitHub
[go: up one dir, main page]

Skip to content

Commit f104647

Browse files
committed
update at 2018-09-27
1 parent bb36021 commit f104647

File tree

9 files changed

+114
-35
lines changed

9 files changed

+114
-35
lines changed

002-add-two-numbers/add-two-numbers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#
66
# You may assume the two numbers do not contain any leading zero, except the number 0 itself.
77
#
8+
# Example:
89
#
9-
# Example
1010
#
1111
# Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
1212
# Output: 7 -> 0 -> 8

003-longest-substring-without-repeating-characters/longest-substring-without-repeating-characters.py

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

44
# Given a string, find the length of the longest substring without repeating characters.
55
#
6-
# Examples:
76
#
8-
# Given "abcabcbb", the answer is "abc", which the length is 3.
7+
# Example 1:
8+
#
9+
#
10+
# Input: "abcabcbb"
11+
# Output: 3
12+
# Explanation: The answer is "abc", with the length of 3.
13+
#
14+
#
15+
#
16+
# Example 2:
17+
#
18+
#
19+
# Input: "bbbbb"
20+
# Output: 1
21+
# Explanation: The answer is "b", with the length of 1.
22+
#
23+
#
24+
#
25+
# Example 3:
26+
#
27+
#
28+
# Input: "pwwkew"
29+
# Output: 3
30+
# Explanation: The answer is "wke", with the length of 3.
31+
# Note that the answer must be a substring, "pwke" is a subsequence and not a substring.
32+
#
33+
#
34+
#
935
#
10-
# Given "bbbbb", the answer is "b", with the length of 1.
1136
#
12-
# Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer must be a substring, "pwke" is a subsequence and not a substring.
1337

1438

1539
class Solution(object):

004-median-of-two-sorted-arrays/median-of-two-sorted-arrays.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55
#
66
# Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).
77
#
8+
# You may assume nums1 and nums2 cannot be both empty.
9+
#
810
# Example 1:
911
#
12+
#
1013
# nums1 = [1, 3]
1114
# nums2 = [2]
1215
#
1316
# The median is 2.0
1417
#
1518
#
16-
#
1719
# Example 2:
1820
#
21+
#
1922
# nums1 = [1, 2]
2023
# nums2 = [3, 4]
2124
#

013-roman-to-integer/roman-to-integer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#
4949
# Input: "LVIII"
5050
# Output: 58
51-
# Explanation: C = 100, L = 50, XXX = 30 and III = 3.
51+
# Exp 67ED lanation: L = 50, V= 5, III = 3.
5252
#
5353
#
5454
# Example 5:

038-count-and-say/count-and-say.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,37 @@
33

44
# The count-and-say sequence is the sequence of integers with the first five terms as following:
55
#
6+
#
67
# 1. 1
78
# 2. 11
89
# 3. 21
910
# 4. 1211
1011
# 5. 111221
1112
#
1213
#
13-
#
1414
# 1 is read off as "one 1" or 11.
1515
# 11 is read off as "two 1s" or 21.
1616
# 21 is read off as "one 2, then one 1" or 1211.
1717
#
18-
#
19-
#
20-
# Given an integer n, generate the nth term of the count-and-say sequence.
21-
#
22-
#
18+
# Given an integer n where 1 ≤ n ≤ 30, generate the nth term of the count-and-say sequence.
2319
#
2420
# Note: Each term of the sequence of integers will be represented as a string.
2521
#
22+
#  
2623
#
2724
# Example 1:
2825
#
26+
#
2927
# Input: 1
3028
# Output: "1"
3129
#
3230
#
33-
#
3431
# Example 2:
3532
#
33+
#
3634
# Input: 4
3735
# Output: "1211"
3836
#
39-
#
4037

4138

4239
class Solution(object):

071-simplify-path/simplify-path.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# -*- coding:utf-8 -*-
22

33

4-
# Given an absolute path for a file (Unix-style), simplify it.
4+
# Given an absolute path for a file (Unix-style), simplify it. 
55
#
66
# For example,
77
# path = "/home/", => "/home"
88
# path = "/a/./b/../../c/", => "/c"
9+
# path = "/a/../../b/../c//.//", => "/c"
10+
# path = "/a//b////c/d//././/..", => "/a/b/c"
11+
#
12+
# In a UNIX-style file system, a period ('.') refers to the current directory, so it can be ignored in a simplified path. Additionally, a double period ("..") moves up a directory, so it cancels out whatever the last directory was. For more information, look here: https://en.wikipedia.org/wiki/Path_(computing)#Unix_style
913
#
1014
# Corner Cases:
1115
#

136-single-number/single-number.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
# Input: [4,1,2,1,2]
2121
# Output: 4
2222
#
23-
#
2423

2524

2625
class Solution(object):

347-top-k-frequent-elements/top-k-frequent-elements.py

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

33

4-
#
54
# Given a non-empty array of integers, return the k most frequent elements.
65
#
7-
# For example,
8-
# Given [1,1,1,2,2,3] and k = 2, return [1,2].
6+
# Example 1:
7+
#
8+
#
9+
# Input: nums = [1,1,1,2,2,3], k = 2
10+
# Output: [1,2]
11+
#
12+
#
13+
#
14+
# Example 2:
15+
#
16+
#
17+
# Input: nums = [1], k = 1
18+
# Output: [1]
919
#
1020
#
1121
# Note:
1222
#
13-
# You may assume k is always valid, 1 ≤ k ≤ number of unique elements.
14-
# Your algorithm's time complexity must be better than O(n log n), where n is the array's size.
23+
#
24+
# You may assume k is always valid, 1 ≤ k ≤ number of unique elements.
25+
# Your algorithm's time complexity must be better than O(n log n), where n is the array's size.
26+
#
1527
#
1628

1729

README.md

Lines changed: 53 additions & 13 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
0