Skip to content

Commit eaf792a

Browse files
author
0x01f7
committed
style: comment
1 parent 061ae03 commit eaf792a

21 files changed

+101
-70
lines changed

algorithms/majority_element.rb

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# https://leetcode.com/problems/majority-element/
22
#
3-
# Given an array of size n, find the majority element. The majority
4-
# element is the element that appears more than n/2 times. You may
5-
# assume that the array is non-empty and the majority element
6-
# always exist in the array.
3+
# Given an array of size n, find the majority element. The majority element is
4+
# the element that appears more than n/2 times. You may assume that the array
5+
# is non-empty and the majority element always exist in the array.
6+
#
7+
# Credits:
8+
#
9+
# Special thanks to @ts for adding this problem and creating all test
10+
# cases.
711

812

913
# @param {Integer[]} nums

algorithms/max_points_on_a_line.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# https://leetcode.com/problems/max-points-on-a-line/
22
#
3-
# Given n points on a 2D plane, find the maximum number of points that lie
4-
# on the same straight line.
3+
# Given n points on a 2D plane, find the maximum number of points that lie on
4+
# the same straight line.
55

66

77
# Definition for a point.

algorithms/maximal_rectangle.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# https://leetcode.com/problems/maximal-rectangle/
22
#
3-
# Given a 2D binary matrix filled with 0's and 1's, find the largest
4-
# rectangle containing all ones and return its area.
3+
# Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle
4+
# containing all ones and return its area.
55

66

77
# @param {Character[][]} matrix

algorithms/maximal_square.rb

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
# https://leetcode.com/problems/maximal-square/
22
#
3-
# Given a 2D binary matrix filled with 0's and 1's, find the largest
4-
# square containing all 1's and return its area.
3+
# Given a 2D binary matrix filled with 0's and 1's, find the largest square
4+
# containing all 1's and return its area.
55
#
6-
# For example, given the following matrix:
6+
# For example:
77
#
8-
# 1 0 1 0 0
9-
# 1 0 1 1 1
10-
# 1 1 1 1 1
11-
# 1 0 0 1 0
8+
# Given the following matrix:
129
#
13-
# Return 4.
10+
# 1 0 1 0 0
11+
# 1 0 1 1 1
12+
# 1 1 1 1 1
13+
# 1 0 0 1 0
14+
#
15+
# Return 4.
16+
#
17+
# Credits:
18+
#
19+
# Special thanks to @Freezen for adding this problem and creating all
20+
# test cases.
1421

1522

1623
# @param {Character[][]} matrix

algorithms/maximum_depth_of_binary_tree.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# https://leetcode.com/problems/maximum-depth-of-binary-tree/
22
#
3-
# Given a binary tree, find its maximum depth. The maximum depth is
4-
# the number of nodes along the longest path from the root node down
5-
# to the farthest leaf node.
3+
# Given a binary tree, find its maximum depth. The maximum depth is the number
4+
# of nodes along the longest path from the root node down to the farthest leaf
5+
# node.
66

77

88
# Definition for a binary tree node.

algorithms/maximum_gap.rb

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# https://leetcode.com/problems/maximum-gap/
22
#
3-
# Given an unsorted array, find the maximum difference between the
4-
# successive elements in its sorted form. Try to solve it in linear
5-
# time/space. Return 0 if the array contains less than 2 elements.
3+
# Given an unsorted array, find the maximum difference between the successive
4+
# elements in its sorted form. Try to solve it in linear time/space. Return 0
5+
# if the array contains less than 2 elements.
66
#
7-
# You may assume all elements in the array are non-negative integers
8-
# and fit in the 32-bit signed integer range.
7+
# You may assume all elements in the array are non-negative integers and fit
8+
# in the 32-bit signed integer range.
9+
#
10+
# Credits:
11+
#
12+
# Special thanks to @porker2008 for adding this problem and creating all
13+
# test cases.
914

1015

1116
# Limits on Integer Constants

algorithms/maximum_product_subarray.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# https://leetcode.com/problems/maximum-product-subarray/
22
#
3-
# Find the contiguous subarray within an array (containing at least one
4-
# number) which has the largest product.
3+
# Find the contiguous subarray within an array (containing at least one number)
4+
# which has the largest product.
55
#
6-
# For example, given the array [2,3,-2,4], the contiguous subarray [2,3]
7-
# has the largest product = 6.
6+
# For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has
7+
# the largest product = 6.
88

99

1010
# @param {Integer[]} nums

algorithms/maximum_subarray.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# https://leetcode.com/problems/maximum-subarray/
22
#
3-
# Find the contiguous subarray within an array (containing at least
4-
# one number) which has the largest sum. For example, given the
5-
# array [−2,1,−3,4,−1,2,1,−5,4], the contiguous subarray [4,−1,2,1]
6-
# has the largest sum = 6.
3+
# Find the contiguous subarray within an array (containing at least one number)
4+
# which has the largest sum. For example, given the array
5+
# [−2, 1, −3, 4, −1, 2, 1, −5, 4], the contiguous subarray [4, −1, 2, 1] has
6+
# the largest sum = 6.
77

88

99
# @param {Integer[]} nums

algorithms/median_of_two_sorted_arrays.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# https://leetcode.com/problems/median-of-two-sorted-arrays/
22
#
3-
# There are two sorted arrays nums1 and nums2 of size m and n
4-
# respectively. Find the median of the two sorted arrays. The
5-
# overall run time complexity should be O(log(m+n)).
3+
# There are two sorted arrays nums1 and nums2 of size m and n respectively.
4+
# Find the median of the two sorted arrays. The overall run time complexity
5+
# should be O(log(m+n)).
66

77

88
# @param {Integer[]} nums1

algorithms/merge_intervals.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#
55
# For example,
66
#
7-
# Given [1,3],[2,6],[8,10],[15,18],
8-
# return [1,6],[8,10],[15,18].
7+
# Given [1, 3], [2, 6], [8, 10], [15, 18],
8+
# Return [1, 6], [8, 10], [15, 18].
99

1010

1111
# Definition for an interval.

algorithms/merge_k_sorted_lists.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# https://leetcode.com/problems/merge-k-sorted-lists/
22
#
3-
# Merge k sorted linked lists and return it as one sorted list. Analyze
4-
# and describe its complexity.
3+
# Merge k sorted linked lists and return it as one sorted list. Analyze and
4+
# describe its complexity.
55

66

77
# Definition for singly-linked list.

algorithms/merge_sorted_array.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# https://leetcode.com/problems/merge-sorted-array/
22
#
3-
# Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1
4-
# as one sorted array.
3+
# Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as
4+
# one sorted array.
55
#
6-
# Note: You may assume that nums1 has enough space (size that is greater
7-
# or equal to m + n) to hold additional elements from nums2. The number of
6+
# Note: You may assume that nums1 has enough space (size that is greater or
7+
# equal to m + n) to hold additional elements from nums2. The number of
88
# elements initialized in nums1 and nums2 are m and n respectively.
99

1010

algorithms/merge_two_sorted_lists.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# https://leetcode.com/problems/merge-two-sorted-lists/
22
#
3-
# Merge two sorted linked lists and return it as a new list. The
4-
# new list should be made by splicing together the nodes of the
5-
# first two lists.
3+
# Merge two sorted linked lists and return it as a new list. The new list
4+
# should be made by splicing together the nodes of the first two lists.
65

76

87
# Definition for singly-linked list.

algorithms/min_stack.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# https://leetcode.com/problems/min-stack/
22
#
3-
# Design a stack that supports push, pop, top, and retrieving the
4-
# minimum element in constant time.
3+
# Design a stack that supports push, pop, top, and retrieving the minimum
4+
# element in constant time.
55
#
66
# push(x) -- Push element x onto stack.
77
# pop() -- Removes the element on top of the stack.

algorithms/minimum_depth_of_binary_tree.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# https://leetcode.com/problems/minimum-depth-of-binary-tree/
22
#
3-
# Given a binary tree, find its minimum depth. The minimum depth
4-
# is the number of nodes along the shortest path from the root
5-
# node down to the nearest leaf node.
3+
# Given a binary tree, find its minimum depth. The minimum depth is the number
4+
# of nodes along the shortest path from the root node down to the nearest leaf
5+
# node.
66

77

88
# Definition for a binary tree node.

algorithms/minimum_path_sum.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# https://leetcode.com/problems/minimum-path-sum/
22
#
3-
# Given a m x n grid filled with non-negative numbers, find a path
4-
# from top left to bottom right which minimizes the sum of all
5-
# numbers along its path.
3+
# Given a m x n grid filled with non-negative numbers, find a path from top
4+
# left to bottom right which minimizes the sum of all numbers along its path.
65
#
76
# Note: You can only move either down or right at any point in time.
87

algorithms/minimum_size_subarray_sum.rb

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# https://leetcode.com/problems/minimum-size-subarray-sum/
22
#
3-
# Given an array of n positive integers and a positive integer s,
4-
# find the minimal length of a subarray of which the sum ≥ s. If
5-
# there isn't one, return 0 instead.
3+
# Given an array of n positive integers and a positive integer s, find the
4+
# minimal length of a subarray of which the sum ≥ s. If there isn't one,
5+
# return 0 instead.
66
#
7-
# For example, given the array [2,3,1,2,4,3] and s = 7, the subarray
8-
# [4,3] has the minimal length under the problem constraint.
7+
# For example, given the array [2, 3, 1, 2, 4, 3] and s = 7, the subarray
8+
# [4, 3] has the minimal length under the problem constraint.
9+
#
10+
# Credits:
11+
#
12+
# Special thanks to @Freezen for adding this problem and creating all
13+
# test cases.
914

1015

1116
# @param {Integer} s

algorithms/minimum_window_substring.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# https://leetcode.com/problems/minimum-window-substring/
22
#
3-
# Given a string S and a string T, find the minimum window in S which
4-
# will contain all the characters in T in complexity O(n).
3+
# Given a string S and a string T, find the minimum window in S which will
4+
# contain all the characters in T in complexity O(n).
55
#
66
# For example,
77
#
88
# S = "ADOBECODEBANC"
99
# T = "ABC"
1010
# Minimum window is "BANC".
1111
#
12-
# Note:
12+
# Notes:
1313
#
1414
# + If there is no such window in S that covers all characters in T,
1515
# return the empty string "".

algorithms/missing_number.rb

+10-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@
33
# Given an array containing n distinct numbers taken from 0, 1, 2, ..., n,
44
# find the one that is missing from the array.
55
#
6-
# For example,
6+
# For example:
77
#
88
# Given nums = [0, 1, 3] return 2.
99
#
10-
# Note: Your algorithm should run in linear runtime complexity. Could you
11-
# implement it using only constant extra space complexity?
10+
# Note:
11+
#
12+
# Your algorithm should run in linear runtime complexity. Could you
13+
# implement it using only constant extra space complexity?
14+
#
15+
# Credits:
16+
#
17+
# Special thanks to @jianchao.li.fighter for adding this problem and
18+
# creating all test cases.
1219

1320

1421
# @param {Integer[]} nums

algorithms/move_zeroes.rb

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
# https://leetcode.com/problems/move-zeroes/
22
#
3-
# Given an array nums, write a function to move all 0's to the end of it
4-
# while maintaining the relative order of the non-zero elements.
3+
# Given an array nums, write a function to move all 0's to the end of it while
4+
# maintaining the relative order of the non-zero elements.
55
#
66
# For example, given nums = [0, 1, 0, 3, 12], after calling your function,
77
# nums should be [1, 3, 12, 0, 0].
88
#
9-
# Note:
9+
# Notes:
1010
#
1111
# + You must do this in-place without making a copy of the array.
1212
# + Minimize the total number of operations.
13+
#
14+
# Credits:
15+
#
16+
# Special thanks to @jianchao.li.fighter for adding this problem and
17+
# creating all test cases.
1318

1419

1520
# @param {Integer[]} nums

algorithms/multiply_strings.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# https://leetcode.com/problems/multiply-strings/
22
#
3-
# Given two numbers represented as strings, return multiplication
4-
# of the numbers as a string.
3+
# Given two numbers represented as strings, return multiplication of the
4+
# numbers as a string.
55
#
66
# Note: The numbers can be arbitrarily large and are non-negative.
77

0 commit comments

Comments
 (0)