Skip to content

Commit 20486c5

Browse files
author
0x01f7
committed
style: comment
1 parent 0975add commit 20486c5

9 files changed

+70
-35
lines changed

algorithms/factorial_trailing_zeroes.rb

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# https://leetcode.com/problems/factorial-trailing-zeroes/
22
#
33
# Given an integer n, return the number of trailing zeroes in n!.
4+
#
5+
# Note:
6+
#
7+
# Your solution should be in logarithmic time complexity.
8+
#
9+
# Credits:
10+
#
11+
# Special thanks to @ts for adding this problem and creating
12+
# all test cases.
413

514

615
# @param {Integer} n

algorithms/find_median_from_data_stream.rb

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# https://leetcode.com/problems/find-median-from-data-stream/
22
#
3-
# Median is the middle value in an ordered integer list. If the size of
4-
# the list is even, there is no middle value. So the median is the mean
5-
# of the two middle value.
3+
# Median is the middle value in an ordered integer list. If the size of the
4+
# list is even, there is no middle value. So the median is the mean of the two
5+
# middle value.
66
#
77
# Examples:
88
#
9-
# [2,3,4] , the median is 3
10-
# [2,3], the median is (2 + 3) / 2 = 2.5
9+
# [2, 3, 4], the median is 3
10+
# [2, 3], the median is (2 + 3) / 2 = 2.5
1111
#
1212
# Design a data structure that supports the following two operations:
1313
#
14-
# + void addNum(int num) - Add a integer number from the data stream
15-
# to the data structure.
14+
# + void addNum(int num) - Add a integer number from the data stream to
15+
# the data structure.
1616
# + double findMedian() - Return the median of all elements so far.
1717
#
1818
# For example:
@@ -22,6 +22,11 @@
2222
# findMedian() -> 1.5
2323
# add(3)
2424
# findMedian() -> 2
25+
#
26+
# Credits:
27+
#
28+
# Special thanks to @Louis1992 for adding this problem and creating all
29+
# test cases.
2530

2631

2732
class PriorityQueue

algorithms/find_minimum_in_rotated_sorted_array.rb

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/
22
#
3-
# Suppose a sorted array is rotated at some pivot unknown to you
4-
# beforehand.
3+
# Suppose a sorted array is rotated at some pivot unknown to you beforehand.
54
#
65
# (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
76
#
8-
# Find the minimum element. You may assume no duplicate exists in
9-
# the array.
7+
# Find the minimum element. You may assume no duplicate exists in the array.
108

119

1210
# @param {Integer[]} nums

algorithms/find_minimum_in_rotated_sorted_array_ii.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
# What if duplicates are allowed?
66
# Would this affect the run-time complexity? How and why?
77
#
8-
# Suppose a sorted array is rotated at some pivot unknown to you
9-
# beforehand.
8+
# Suppose a sorted array is rotated at some pivot unknown to you beforehand.
109
#
1110
# (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
1211
#

algorithms/find_peak_element.rb

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
# https://leetcode.com/problems/find-peak-element/
22
#
3-
# A peak element is an element that is greater than its neighbors. Given
4-
# an input array where num[i] != num[i+1], find a peak element and return
5-
# its index. The array may contain multiple peaks, in that case return
6-
# the index to any one of the peaks is fine. You may imagine that
3+
# A peak element is an element that is greater than its neighbors. Given an
4+
# input array where num[i] != num[i+1], find a peak element and return its
5+
# index. The array may contain multiple peaks, in that case return the index
6+
# to any one of the peaks is fine. You may imagine that
77
# num[-1] = num[n] = -Inf.
88
#
9-
# For example, in array [1, 2, 3, 1], 3 is a peak element and your
10-
# function should return the index number 2.
9+
# For example, in array [1, 2, 3, 1], 3 is a peak element and your function
10+
# should return the index number 2.
11+
#
12+
# Note:
13+
#
14+
# Your solution should be in logarithmic complexity.
15+
#
16+
# Credits:
17+
#
18+
# Special thanks to @ts for adding this problem and creating all test
19+
# cases.
1120

1221

1322
# @param {Integer[]} nums

algorithms/find_the_duplicate_number.rb

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
# https://leetcode.com/problems/find-the-duplicate-number/
22
#
3-
# Given an array nums containing n + 1 integers where each integer is
4-
# between 1 and n (inclusive), prove that at least one duplicate
5-
# number must exist. Assume that there is only one duplicate number,
6-
# find the duplicate one.
3+
# Given an array nums containing n + 1 integers where each integer is between
4+
# 1 and n (inclusive), prove that at least one duplicate number must exist.
5+
# Assume that there is only one duplicate number, find the duplicate one.
76
#
8-
# Note:
7+
# Notes:
98
#
109
# + You must not modify the array (assume the array is read only).
1110
# + You must use only constant, O(1) extra space.
1211
# + Your runtime complexity should be less than O(n2).
13-
# + There is only one duplicate number in the array, but it could
14-
# be repeated more than once.
12+
# + There is only one duplicate number in the array, but it could be
13+
# repeated more than once.
14+
#
15+
# Credits:
16+
#
17+
# Special thanks to @jianchao.li.fighter for adding this problem and
18+
# creating all test cases.
1519

1620

1721
# @param {Integer[]} nums

algorithms/first_bad_version.rb

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
# https://leetcode.com/problems/first-bad-version/
22
#
33
# You are a product manager and currently leading a team to develop a new
4-
# product. Unfortunately, the latest version of your product fails the
5-
# quality check. Since each version is developed based on the previous
6-
# version, all the versions after a bad version are also bad.
4+
# product. Unfortunately, the latest version of your product fails the quality
5+
# check. Since each version is developed based on the previous version, all
6+
# the versions after a bad version are also bad.
77
#
88
# Suppose you have n versions [1, 2, ..., n] and you want to find out the
99
# first bad one, which causes all the following ones to be bad.
1010
#
1111
# You are given an API bool isBadVersion(version) which will return whether
1212
# version is bad. Implement a function to find the first bad version. You
1313
# should minimize the number of calls to the API.
14+
#
15+
# Credits:
16+
#
17+
# Special thanks to @jianchao.li.fighter for adding this problem and
18+
# creating all test cases.
1419

1520

1621
# The is_bad_version API is already defined for you.

algorithms/first_missing_positive.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# https://leetcode.com/problems/first-missing-positive/
22
#
3-
# Given an unsorted integer array, find the first missing positive
4-
# integer.
3+
# Given an unsorted integer array, find the first missing positive integer.
54
#
6-
# For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2.
5+
# For example:
6+
#
7+
# Given [1,2,0] return 3, and [3,4,-1,1] return 2.
78
#
89
# Your algorithm should run in O(n) time and uses constant space.
910

algorithms/fraction_to_recurring_decimal.rb

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
# https://leetcode.com/problems/fraction-to-recurring-decimal/
22
#
3-
# Given two integers representing the numerator and denominator of a
4-
# fraction, return the fraction in string format. If the fractional
5-
# part is repeating, enclose the repeating part in parentheses.
3+
# Given two integers representing the numerator and denominator of a fraction,
4+
# return the fraction in string format. If the fractional part is repeating,
5+
# enclose the repeating part in parentheses.
66
#
77
# For example,
88
#
99
# Given numerator = 1, denominator = 2, return "0.5".
1010
# Given numerator = 2, denominator = 1, return "2".
1111
# Given numerator = 2, denominator = 3, return "0.(6)".
12+
#
13+
# Credits:
14+
#
15+
# Special thanks to @Shangrila for adding this problem and creating all
16+
# test cases.
1217

1318

1419
# @param {integer} numerator

0 commit comments

Comments
 (0)