Skip to content

Commit aef10c1

Browse files
author
0x01f7
committed
style: comment
1 parent 3d80a07 commit aef10c1

13 files changed

+68
-55
lines changed

Diff for: algorithms/palindrome_partitioning.rb

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# https://leetcode.com/problems/palindrome-partitioning/
22
#
3-
# Given a string s, partition s such that every substring of the
4-
# partition is a palindrome.
5-
#
6-
# Return all possible palindrome partitioning of s.
3+
# Given a string s, partition s such that every substring of the partition is
4+
# a palindrome. Return all possible palindrome partitioning of s.
75
#
86
# For example, given s = "aab", Return
97
#

Diff for: algorithms/palindrome_partitioning_ii.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# https://leetcode.com/problems/palindrome-partitioning-ii/
22
#
3-
# Given a string s, partition s such that every substring of the
4-
# partition is a palindrome. Return the minimum cuts needed for
5-
# a palindrome partitioning of s.
3+
# Given a string s, partition s such that every substring of the partition is
4+
# a palindrome. Return the minimum cuts needed for a palindrome partitioning
5+
# of s.
66
#
7-
# For example, given s = "aab", Return 1 since the palindrome
8-
# partitioning ["aa","b"] could be produced using 1 cut.
7+
# For example, given s = "aab", Return 1 since the palindrome partitioning
8+
# ["aa","b"] could be produced using 1 cut.
99

1010

1111
# @param {String} s

Diff for: algorithms/partition_list.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# https://leetcode.com/problems/partition-list/
22
#
3-
# Given a linked list and a value x, partition it such that all nodes
4-
# less than x come before nodes greater than or equal to x.
3+
# Given a linked list and a value x, partition it such that all nodes less
4+
# than x come before nodes greater than or equal to x.
55
#
6-
# You should preserve the original relative order of the nodes in
7-
# each of the two partitions.
6+
# You should preserve the original relative order of the nodes in each of the
7+
# two partitions.
88
#
9-
# For example,
9+
# For example:
1010
#
1111
# Given 1->4->3->2->5->2 and x = 3,
12-
# return 1->2->2->4->3->5.
12+
# Return 1->2->2->4->3->5.
1313

1414

1515
# Definition for singly-linked list.

Diff for: algorithms/pascals_triangle_ii.rb

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
# Given an index k, return the kth row of the Pascal's triangle.
44
#
55
# For example, given k = 3, Return [1,3,3,1].
6+
#
7+
# Note:
8+
#
9+
# Could you optimize your algorithm to use only O(k) extra space?
610

711

812
# @param {Integer} row_index

Diff for: algorithms/path_sum.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# https://leetcode.com/problems/path-sum/
22
#
3-
# Given a binary tree and a sum, determine if the tree has a
4-
# root-to-leaf path such that adding up all the values along
5-
# the path equals the given sum.
3+
# Given a binary tree and a sum, determine if the tree has a root-to-leaf path
4+
# such that adding up all the values along the path equals the given sum.
65
#
76
# For example:
87
#
@@ -16,7 +15,7 @@
1615
# / \ \
1716
# 7 2 1
1817
#
19-
# return true, as there exist a root-to-leaf
18+
# Return true, as there exist a root-to-leaf
2019
# path 5->4->11->2 which sum is 22.
2120

2221

Diff for: algorithms/path_sum_ii.rb

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
# https://leetcode.com/problems/path-sum-ii/
22
#
3-
# Given a binary tree and a sum, find all root-to-leaf paths where
4-
# each path's sum equals the given sum.
3+
# Given a binary tree and a sum, find all root-to-leaf paths where each path's
4+
# sum equals the given sum.
55
#
6-
# For example: Given the below binary tree and sum = 22,
6+
# For example:
77
#
8-
# 5
9-
# / \
10-
# 4 8
11-
# / / \
12-
# 11 13 4
13-
# / \ / \
14-
# 7 2 5 1
8+
# Given the below binary tree and sum = 22,
159
#
16-
# return
10+
# 5
11+
# / \
12+
# 4 8
13+
# / / \
14+
# 11 13 4
15+
# / \ / \
16+
# 7 2 5 1
1717
#
18-
# [
19-
# [5,4,11,2],
20-
# [5,8,4,5]
21-
# ]
18+
# Return
19+
#
20+
# [
21+
# [5, 4, 11, 2],
22+
# [5, 8, 4, 5]
23+
# ]
2224

2325

2426
# Definition for a binary tree node.

Diff for: algorithms/perfect_squares.rb

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# https://leetcode.com/problems/perfect-squares/
22
#
3-
# Given a positive integer n, find the least number of perfect square
4-
# numbers (for example, 1, 4, 9, 16, ...) which sum to n.
3+
# Given a positive integer n, find the least number of perfect square numbers
4+
# (for example, 1, 4, 9, 16, ...) which sum to n.
55
#
66
# For example,
77
#
88
# given n = 12, return 3 because 12 = 4 + 4 + 4;
99
# given n = 13, return 2 because 13 = 4 + 9.
10+
#
11+
# Credits:
12+
#
13+
# Special thanks to @jianchao.li.fighter for adding this problem and
14+
# creating all test cases.
1015

1116

1217
# @param {Integer} n

Diff for: algorithms/permutation_sequence.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# https://leetcode.com/problems/permutation-sequence/
22
#
3-
# The set [1,2,3,…,n] contains a total of n! unique permutations.
4-
# By listing and labeling all of the permutations in order, We
5-
# get the following sequence (ie, for n = 3):
3+
# The set [1,2,3,…,n] contains a total of n! unique permutations. By listing
4+
# and labeling all of the permutations in order, We get the following sequence
5+
# (ie, for n = 3):
66
#
77
# 1. "123"
88
# 2. "132"

Diff for: algorithms/permutations.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#
55
# For example,
66
#
7-
# [1,2,3] have the following permutations:
8-
# [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]
7+
# [1, 2, 3] have the following permutations:
8+
# [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], and [3, 2, 1]
99

1010

1111
# @param {Integer[]} nums

Diff for: algorithms/permutations_ii.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# https://leetcode.com/problems/permutations-ii/
22
#
3-
# Given a collection of numbers that might contain duplicates, return
4-
# all possible unique permutations.
3+
# Given a collection of numbers that might contain duplicates, return all
4+
# possible unique permutations.
55
#
66
# For example,
77
#
8-
# [1,1,2] have the following unique permutations:
9-
# [1,1,2], [1,2,1], and [2,1,1].
8+
# [1, 1, 2] have the following unique permutations:
9+
# [1, 1, 2], [1, 2, 1], and [2, 1, 1].
1010

1111

1212
# @param {Integer[]} nums

Diff for: algorithms/plus_one.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# https://leetcode.com/problems/plus-one/
22
#
3-
# Given a non-negative number represented as an array of digits, plus
4-
# one to the number. The digits are stored such that the most significant
5-
# digit is at the head of the list.
3+
# Given a non-negative number represented as an array of digits, plus one to
4+
# the number. The digits are stored such that the most significant digit is
5+
# at the head of the list.
66

77

88
# @param {Integer[]} digits

Diff for: algorithms/power_of_two.rb

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# https://leetcode.com/problems/power-of-two/
22
#
33
# Given an integer, write a function to determine if it is a power of two.
4+
#
5+
# Credits:
6+
#
7+
# Special thanks to @jianchao.li.fighter for adding this problem and
8+
# creating all test cases.
49

510

611
# @param {Integer} n

Diff for: algorithms/product_of_array_except_self.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# https://leetcode.com/problems/product-of-array-except-self/
22
#
3-
# Given an array of n integers where n > 1, nums, return an array
4-
# output such that output[i] is equal to the product of all the
5-
# elements of nums except nums[i].
3+
# Given an array of n integers where n > 1, nums, return an array output such
4+
# that output[i] is equal to the product of all the elements of nums except
5+
# nums[i].
66
#
77
# Solve it without division and in O(n).
88
#
9-
# For example, given [1,2,3,4], return [24,12,8,6].
9+
# For example, given [1, 2, 3, 4], return [24, 12, 8, 6].
1010
#
11-
# Follow up: Could you solve it with constant space complexity? (Note:
12-
# The output array does not count as extra space for the purpose of
13-
# space complexity analysis.)
11+
# Follow up: Could you solve it with constant space complexity? (Note: The
12+
# output array does not count as extra space for the purpose of space
13+
# complexity analysis.)
1414

1515

1616
# @param {Integer[]} nums

0 commit comments

Comments
 (0)