Skip to content

Commit d087331

Browse files
author
0x01f7
committed
style: comment
1 parent 0596778 commit d087331

11 files changed

+67
-47
lines changed

algorithms/compare_version_numbers.rb

+9-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
# Compare two version numbers version1 and version2. If version1 > version2
44
# return 1, if version1 < version2 return -1, otherwise return 0. You may
55
# assume that the version strings are non-empty and contain only digits and
6-
# the . character. The . character does not represent a decimal point and
7-
# is used to separate number sequences. For instance, 2.5 is not "two and a
8-
# half" or "half way to version three", it is the fifth second-level
9-
# revision of the second first-level revision. Here is an example of
10-
# version numbers ordering:
6+
# the . character. The . character does not represent a decimal point and is
7+
# used to separate number sequences. For instance, 2.5 is not "two and a half"
8+
# or "half way to version three", it is the fifth second-level revision of the
9+
# second first-level revision. Here is an example of version numbers ordering:
1110
#
1211
# 0.1 < 1.1 < 1.2 < 13.37
12+
#
13+
# Credits:
14+
#
15+
# Special thanks to @ts for adding this problem and creating all test
16+
# cases.
1317

1418

1519
# @param {String} version1

algorithms/container_with_most_water.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# https://leetcode.com/problems/container-with-most-water/
22
#
3-
# Given n non-negative integers a1, a2, ..., an, where each represents
4-
# a point at coordinate (i, ai). n vertical lines are drawn such that
5-
# the two endpoints of line i is at (i, ai) and (i, 0). Find two lines,
6-
# which together with x-axis forms a container, such that the container
7-
# contains the most water.
3+
# Given n non-negative integers a1, a2, ..., an, where each represents a point
4+
# at coordinate (i, ai). n vertical lines are drawn such that the two
5+
# endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together
6+
# with x-axis forms a container, such that the container contains the most
7+
# water.
88
#
99
# Note: You may not slant the container.
1010

algorithms/contains_duplicate.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# https://leetcode.com/problems/contains-duplicate/
22
#
3-
# Given an array of integers, find if the array contains any duplicates.
4-
# Your function should return true if any value appears at least twice
5-
# in the array, and it should return false if every element is distinct.
3+
# Given an array of integers, find if the array contains any duplicates. Your
4+
# function should return true if any value appears at least twice in the array,
5+
# and it should return false if every element is distinct.
66

77

88
# @param {Integer[]} nums

algorithms/contains_duplicate_ii.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# https://leetcode.com/problems/contains-duplicate-ii/
22
#
3-
# Given an array of integers and an integer k, find out whether there
4-
# are two distinct indices i and j in the array such that
5-
# nums[i] = nums[j] and the difference between i and j is at most k.
3+
# Given an array of integers and an integer k, find out whether there are two
4+
# distinct indices i and j in the array such that nums[i] = nums[j] and the
5+
# difference between i and j is at most k.
66

77

88
# @param {Integer[]} nums

algorithms/contains_duplicate_iii.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# https://leetcode.com/problems/contains-duplicate-iii/
22
#
3-
# Given an array of integers, find out whether there are two distinct
4-
# indices i and j in the array such that the difference between
5-
# nums[i] and nums[j] is at most t and the difference between i and j
6-
# is at most k.
3+
# Given an array of integers, find out whether there are two distinct indices
4+
# i and j in the array such that the difference between nums[i] and nums[j] is
5+
# at most t and the difference between i and j is at most k.
76

87

98
# @param {Integer[]} nums

algorithms/convert_sorted_array_to_binary_search_tree.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/
22
#
3-
# Given an array where elements are sorted in ascending order, convert
4-
# it to a height balanced BST.
3+
# Given an array where elements are sorted in ascending order, convert it to a
4+
# height balanced BST.
55

66

77
# Definition for a binary tree node.

algorithms/count_and_say.rb

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# https://leetcode.com/problems/count-and-say/
22
#
3-
# The count-and-say sequence is the sequence of integers beginning
4-
# as follows:
3+
# The count-and-say sequence is the sequence of integers beginning as follows:
54
#
65
# 1, 11, 21, 1211, 111221, ...
76
#
8-
# 1 is read off as "one 1" or 11.
9-
# 11 is read off as "two 1s" or 21.
10-
# 21 is read off as "one 2, then one 1" or 1211.
7+
# 1 is read off as "one 1" or 11.
8+
# 11 is read off as "two 1s" or 21.
9+
# 21 is read off as "one 2, then one 1" or 1211.
1110
#
1211
# Given an integer n, generate the nth sequence.
12+
#
13+
# Note: The sequence of integers will be represented as a string.
1314

1415

1516
# @param {Integer} n

algorithms/count_complete_tree_nodes.rb

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# https://leetcode.com/problems/count-complete-tree-nodes/
22
#
33
# Given a complete binary tree, count the number of nodes.
4+
#
5+
# Definition of a complete binary tree from Wikipedia: In a complete binary
6+
# tree every level, except possibly the last, is completely filled, and all
7+
# nodes in the last level are as far left as possible. It can have between
8+
# 1 and 2h nodes inclusive at the last level h.
49

510

611
# Definition for a binary tree node.

algorithms/count_primes.rb

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# https://leetcode.com/problems/count-primes/
22
#
33
# Count the number of prime numbers less than a non-negative number, n.
4+
#
5+
# Credits:
6+
#
7+
# Special thanks to @mithmatt for adding this problem and creating all
8+
# test cases.
49

510

611
# @param {Integer} n

algorithms/course_schedule.rb

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
# https://leetcode.com/problems/course-schedule/
22
#
33
# There are a total of n courses you have to take, labeled from 0 to n - 1.
4-
# Some courses may have prerequisites, for example to take course 0 you
5-
# have to first take course 1, which is expressed as a pair: [0,1]. Given
6-
# the total number of courses and a list of prerequisite pairs, is it
7-
# possible for you to finish all courses?
4+
# Some courses may have prerequisites, for example to take course 0 you have
5+
# to first take course 1, which is expressed as a pair: [0,1]. Given the total
6+
# number of courses and a list of prerequisite pairs, is it possible for you
7+
# to finish all courses?
88
#
99
# For example:
1010
#
11-
# 2, [[1,0]]
11+
# 2, [[1, 0]]
1212
#
13-
# There are a total of 2 courses to take. To take course 1 you should
14-
# have finished course 0. So it is possible.
13+
# There are a total of 2 courses to take. To take course 1 you should have
14+
# finished course 0. So it is possible.
1515
#
16-
# 2, [[1,0],[0,1]]
16+
# 2, [[1, 0], [0, 1]]
1717
#
18-
# There are a total of 2 courses to take. To take course 1 you should
19-
# have finished course 0, and to take course 0 you should also have
20-
# finished course 1. So it is impossible.
18+
# There are a total of 2 courses to take. To take course 1 you should have
19+
# finished course 0, and to take course 0 you should also have finished course
20+
# 1. So it is impossible.
21+
#
22+
# Note: The input prerequisites is a graph represented by a list of edges, not
23+
# adjacency matrices.
2124

2225

2326
# @param {Integer} num_courses

algorithms/course_schedule_ii.rb

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
# https://leetcode.com/problems/course-schedule-ii/
22
#
33
# There are a total of n courses you have to take, labeled from 0 to n - 1.
4-
# Some courses may have prerequisites, for example to take course 0 you
5-
# have to first take course 1, which is expressed as a pair: [0,1]. Given
6-
# the total number of courses and a list of prerequisite pairs, return the
7-
# ordering of courses you should take to finish all courses.
4+
# Some courses may have prerequisites, for example to take course 0 you have
5+
# to first take course 1, which is expressed as a pair: [0,1]. Given the total
6+
# number of courses and a list of prerequisite pairs, return the ordering of
7+
# courses you should take to finish all courses.
88
#
99
# There may be multiple correct orders, you just need to return one of them.
1010
# If it is impossible to finish all courses, return an empty array.
1111
#
1212
# For example:
1313
#
14-
# 2, [[1,0]]
14+
# 2, [[1, 0]]
1515
#
1616
# There are a total of 2 courses to take. To take course 1 you should have
17-
# finished course 0. So the correct course order is [0,1]
17+
# finished course 0. So the correct course order is [0, 1]
1818
#
19-
# 4, [[1,0],[2,0],[3,1],[3,2]]
19+
# 4, [[1, 0], [2, 0], [3, 1], [3, 2]]
2020
#
2121
# There are a total of 4 courses to take. To take course 3 you should have
2222
# finished both courses 1 and 2. Both courses 1 and 2 should be taken after
23-
# you finished course 0. So one correct course order is [0,1,2,3]. Another
24-
# correct ordering is [0,2,1,3].
23+
# you finished course 0. So one correct course order is [0, 1, 2, 3]. Another
24+
# correct ordering is [0, 2, 1, 3].
25+
#
26+
# Note: The input prerequisites is a graph represented by a list of edges, not
27+
# adjacency matrices.
2528

2629

2730
# @param {Integer} num_courses

0 commit comments

Comments
 (0)