Skip to content

Commit d38eca0

Browse files
author
0x01f7
committed
style: comment
1 parent 634b55a commit d38eca0

19 files changed

+138
-101
lines changed

algorithms/add_and_search_word_data_structure_design.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
# search(".ad") -> true
1919
# search("b..") -> true
2020
#
21-
# Note: You may assume that all words are consist of lowercase letters a-z.
21+
# Note:
22+
#
23+
# You may assume that all words are consist of lowercase letters a-z.
2224

2325

2426
class TrieNode

algorithms/balanced_binary_tree.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# https://leetcode.com/problems/balanced-binary-tree/
22
#
3-
# Given a binary tree, determine if it is height-balanced. For this
4-
# problem, a height-balanced binary tree is defined as a binary
5-
# tree in which the depth of the two subtrees of every node never
6-
# differ by more than 1.
3+
# Given a binary tree, determine if it is height-balanced. For this problem,
4+
# a height-balanced binary tree is defined as a binary tree in which the
5+
# depth of the two subtrees of every node never differ by more than 1.
76

87

98
# Definition for a binary tree node.

algorithms/basic_calculator.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# https://leetcode.com/problems/basic-calculator/
22
#
3-
# Implement a basic calculator to evaluate a simple expression string.
4-
# The expression string may contain open ( and closing parentheses ),
5-
# the plus + or minus sign -, non-negative integers and empty spaces.
6-
# You may assume that the given expression is always valid.
3+
# Implement a basic calculator to evaluate a simple expression string. The
4+
# expression string may contain open ( and closing parentheses ), the plus
5+
# + or minus sign -, non-negative integers and empty spaces. You may assume
6+
# that the given expression is always valid.
77
#
88
# Some examples:
99
#

algorithms/basic_calculator_ii.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
# https://leetcode.com/problems/basic-calculator-ii/
22
#
3-
# Implement a basic calculator to evaluate a simple expression string.
4-
# The expression string contains only non-negative integers, +, -, *,
5-
# / operators and empty spaces. The integer division should truncate
6-
# toward zero. You may assume that the given expression is always valid.
3+
# Implement a basic calculator to evaluate a simple expression string. The
4+
# expression string contains only non-negative integers, +, -, *, / operators
5+
# and empty spaces. The integer division should truncate toward zero. You may
6+
# assume that the given expression is always valid.
77
#
88
# Some examples:
99
#
1010
# "3+2*2" = 7
1111
# " 3/2 " = 1
1212
# " 3+5 / 2 " = 5
1313
#
14-
# Note: Do not use the eval built-in library function.
14+
# Note:
15+
#
16+
# Do not use the eval built-in library function.
17+
#
18+
# Credits:
19+
#
20+
# Special thanks to @ts for adding this problem and creating all test
21+
# cases.
1522

1623

1724
# @param {String} s

algorithms/best_time_to_buy_and_sell_stock.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
22
#
3-
# Say you have an array for which the ith element is the price of a
4-
# given stock on day i. If you were only permitted to complete at
5-
# most one transaction (ie, buy one and sell one share of the stock),
6-
# design an algorithm to find the maximum profit.
3+
# Say you have an array for which the ith element is the price of a given
4+
# stock on day i. If you were only permitted to complete at most one
5+
# transaction (ie, buy one and sell one share of the stock), design an
6+
# algorithm to find the maximum profit.
77

88

99
# @param {Integer[]} prices

algorithms/best_time_to_buy_and_sell_stock_ii.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/
22
#
3-
# Say you have an array for which the ith element is the price of a
4-
# given stock on day i. Design an algorithm to find the maximum
5-
# profit. You may complete as many transactions as you like (ie,
6-
# buy one and sell one share of the stock multiple times). However,
7-
# you may not engage in multiple transactions at the same time (ie,
8-
# you must sell the stock before you buy again).
3+
# Say you have an array for which the ith element is the price of a given
4+
# stock on day i. Design an algorithm to find the maximum profit. You may
5+
# complete as many transactions as you like (ie, buy one and sell one share
6+
# of the stock multiple times). However, you may not engage in multiple
7+
# transactions at the same time (ie, you must sell the stock before you buy
8+
# again).
99

1010

1111
# @param {Integer[]} prices

algorithms/best_time_to_buy_and_sell_stock_iii.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/
22
#
3-
# Say you have an array for which the ith element is the price of a
4-
# given stock on day i. Design an algorithm to find the maximum
5-
# profit. You may complete at most two transactions. However,
6-
# You may not engage in multiple transactions at the same time (ie,
7-
# you must sell the stock before you buy again).
3+
# Say you have an array for which the ith element is the price of a given
4+
# stock on day i. Design an algorithm to find the maximum profit. You may
5+
# complete at most two transactions. However, You may not engage in multiple
6+
# transactions at the same time (ie, you must sell the stock before you buy
7+
# again).
88

99

1010
# @param {Integer[]} prices

algorithms/best_time_to_buy_and_sell_stock_iv.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/
22
#
3-
# Say you have an array for which the ith element is the price of a
4-
# given stock on day i. Design an algorithm to find the maximum
5-
# profit. You may complete at most k transactions. However,
6-
# You may not engage in multiple transactions at the same time (ie,
7-
# you must sell the stock before you buy again).
3+
# Say you have an array for which the ith element is the price of a given
4+
# stock on day i. Design an algorithm to find the maximum profit. You may
5+
# complete at most k transactions. However, You may not engage in multiple
6+
# transactions at the same time (ie, you must sell the stock before you buy
7+
# again).
8+
#
9+
# Credits:
10+
#
11+
# Special thanks to @Freezen for adding this problem and creating all
12+
# test cases.
813

914

1015
# @param {Integer} k

algorithms/binary_search_tree_iterator.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
# https://leetcode.com/problems/binary-search-tree-iterator/
22
#
3-
# Implement an iterator over a binary search tree (BST). Your iterator
4-
# will be initialized with the root node of a BST.
3+
# Implement an iterator over a binary search tree (BST). Your iterator will
4+
# be initialized with the root node of a BST. Calling next() will return the
5+
# next smallest number in the BST.
56
#
6-
# Calling next() will return the next smallest number in the BST.
7+
# Note:
78
#
8-
# Note: next() and hasNext() should run in average O(1) time and uses
9-
# O(h) memory, where h is the height of the tree.
9+
# next() and hasNext() should run in average O(1) time and uses O(h)
10+
# memory, where h is the height of the tree.
11+
#
12+
# Credits:
13+
#
14+
# Special thanks to @ts for adding this problem and creating all test
15+
# cases.
1016

1117

1218
# Definition for a binary tree node.

algorithms/binary_tree_inorder_traversal.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
# https://leetcode.com/problems/binary-tree-inorder-traversal/
22
#
3-
# Given a binary tree, return the inorder traversal of its nodes'
4-
# values.
3+
# Given a binary tree, return the inorder traversal of its nodes' values.
54
#
65
# For example:
76
#
8-
# Given binary tree {1,#,2,3},
7+
# Given binary tree {1, #, 2, 3},
98
#
109
# 1
1110
# \
1211
# 2
1312
# /
1413
# 3
1514
#
16-
# return [1,3,2].
15+
# Return [1, 3, 2].
1716
#
1817
# Note: Recursive solution is trivial, could you do it iteratively?
1918

0 commit comments

Comments
 (0)