Skip to content

Commit a855564

Browse files
committed
Format docstrings
1 parent b8ed49e commit a855564

16 files changed

+46
-52
lines changed

problems/problem_0002.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
88
You may assume the two numbers do not contain any leading zero,
99
except the number 0 itself.
10-
1110
"""
1211

1312

problems/problem_0011.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
from typing import List
2-
1+
"""Given n non-negative integers a1, a2, ..., an,
2+
where each represents a point at coordinate (i, ai),
3+
n vertical lines are drawn
4+
such that the two endpoints of line i is at (i, ai)
5+
and (i, 0).
36
4-
class Solution:
5-
"""Given n non-negative integers a1, a2, ..., an,
6-
where each represents a point at coordinate (i, ai),
7-
n vertical lines are drawn
8-
such that the two endpoints of line i is at (i, ai)
9-
and (i, 0).
7+
Find two lines, which together with x-axis forms a container,
8+
such that the container contains the most water.
9+
"""
1010

11-
Find two lines, which together with x-axis forms a container,
12-
such that the container contains the most water.
11+
from typing import List
1312

14-
"""
1513

14+
class Solution:
1615
def maxArea(self, height: List[int]) -> int:
1716

1817
idx0, idx1 = 0, len(height) - 1

problems/problem_0013.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Given a roman numeral, convert it to an integer.
2-
Input is guaranteed to be within the range from 1 to 3999."""
2+
Input is guaranteed to be within the range from 1 to 3999.
3+
"""
34

45

56
class Solution:

problems/problem_0015.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
from typing import List
1+
"""Given an array nums of n integers,
2+
are there elements a, b, c in nums such that a + b + c = 0?
23
4+
Find all unique triplets in the array which gives the sum of zero.
5+
Notice that the solution set must not contain duplicate triplets.
6+
"""
37

4-
class Solution:
5-
"""Given an array nums of n integers,
6-
are there elements a, b, c in nums such that a + b + c = 0?
8+
from typing import List
79

8-
Find all unique triplets in the array which gives the sum of zero.
9-
Notice that the solution set must not contain duplicate triplets.
10-
"""
1110

11+
class Solution:
1212
def threeSum(self, nums: List[int]) -> List[List[int]]:
1313

1414
nums = sorted(nums)

problems/problem_0026.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
Do not allocate extra space for another array, you must do this
55
by modifying the input array in-place with O(1) extra memory.
66
7-
It doesn't matter what you leave beyond the returned length."""
7+
It doesn't matter what you leave beyond the returned length.
8+
"""
89

910

1011
class Solution:

problems/problem_0027.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
you must do this by modifying the input array in-place with O(1) extra memory.
66
77
The order of elements can be changed.
8-
It doesn't matter what you leave beyond the new length."""
8+
It doesn't matter what you leave beyond the new length.
9+
"""
910

1011

1112
class Solution:

problems/problem_0028.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
or -1 if needle is not part of haystack.
33
44
For the purpose of this problem, we will return 0 when needle is an empty string.
5-
65
"""
76

87

problems/problem_0075.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Given an array with n objects colored red, white or blue,
1+
"""Given an array with n objects colored red, white or blue,
32
sort them so that objects of the same color are adjacent,
43
with the colors in the order red, white and blue.
54

problems/problem_0198.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1+
"""You are a professional robber planning to rob houses along a street.
2+
Each house has a certain amount of money stashed,
3+
the only constraint stopping you from robbing each of them
4+
is that adjacent houses have security system connected and
5+
it will automatically contact the police
6+
if two adjacent houses were broken into
7+
on the same night.
8+
9+
Given a list of non-negative integers
10+
representing the amount of money of each house,
11+
determine the maximum amount of money you can rob tonight
12+
without alerting the police.
13+
"""
14+
115
from typing import List
216

317

418
class Solution:
5-
"""You are a professional robber planning to rob houses along a street.
6-
Each house has a certain amount of money stashed,
7-
the only constraint stopping you from robbing each of them
8-
is that adjacent houses have security system connected and
9-
it will automatically contact the police
10-
if two adjacent houses were broken into
11-
on the same night.
12-
13-
Given a list of non-negative integers
14-
representing the amount of money of each house,
15-
determine the maximum amount of money you can rob tonight
16-
without alerting the police.
17-
"""
18-
1919
def rob(self, nums: List[int]) -> int:
2020

2121
rob0, rob1 = 0, 0

problems/problem_0442.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array),
1+
"""Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array),
32
some elements appear twice and others appear once.
43
54
Find all the elements that appear twice in this array.

problems/problem_0500.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Given a List of words, return the words that can be typed using letters of alphabet
2-
on only one row's of American keyboard like the image below."""
2+
on only one row's of American keyboard like the image below.
3+
"""
34

45

56
class Solution:

problems/problem_0513.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Given a binary tree, find the leftmost value in the last row of the tree.
1+
"""Given a binary tree, find the leftmost value in the last row of the tree.
32
43
Example 1:
54
Input:

problems/problem_0515.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
You need to find the largest value in each row of a binary tree.
1+
"""You need to find the largest value in each row of a binary tree.
32
43
Example:
54
Input:

problems/problem_0654.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Given an integer array with no duplicates.
1+
"""Given an integer array with no duplicates.
32
43
A maximum tree building on this array is defined as follows:
54

problems/problem_0657.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Initially, there is a Robot at position (0, 0). Given a sequence of its moves,
1+
"""Initially, there is a Robot at position (0, 0). Given a sequence of its moves,
32
judge if this robot makes a circle, which means it moves back to the original place.
43
54
The move sequence is represented by a string. And each move is represent by a character.

problems/problem_0674.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Given an unsorted array of integers, find the length of longest continuous
1+
"""Given an unsorted array of integers, find the length of longest continuous
32
increasing subsequence (subarray).
43
54
Example 1:

0 commit comments

Comments
 (0)