Skip to content

Commit addc5a1

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

6 files changed

+47
-43
lines changed

algorithms/decode_ways.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# https://leetcode.com/problems/decode-ways/
22
#
3-
# A message containing letters from A-Z is being encoded to numbers
4-
# using the following mapping:
3+
# A message containing letters from A-Z is being encoded to numbers using the
4+
# following mapping:
55
#
66
# 'A' -> 1
77
# 'B' -> 2
88
# ...
99
# 'Z' -> 26
1010
#
11-
# Given an encoded message containing digits, determine the total
12-
# number of ways to decode it.
11+
# Given an encoded message containing digits, determine the total number of
12+
# ways to decode it.
1313
#
14-
# For example, Given encoded message "12", it could be decoded as
15-
# "AB" (1 2) or "L" (12). The number of ways decoding "12" is 2.
14+
# For example, Given encoded message "12", it could be decoded as "AB" (1 2)
15+
# or "L" (12). The number of ways decoding "12" is 2.
1616

1717

1818
# @param {String} s

algorithms/delete_node_in_a_linked_list.rb

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# https://leetcode.com/problems/delete-node-in-a-linked-list/
22
#
3-
# Write a function to delete a node (except the tail) in a singly
4-
# linked list, given only access to that node. Supposed the linked
5-
# list is 1 -> 2 -> 3 -> 4 and you are given the third node with
6-
# value 3, the linked list should become 1 -> 2 -> 4 after calling
7-
# your function.
3+
# Write a function to delete a node (except the tail) in a singly linked list,
4+
# given only access to that node. Supposed the linked list is 1 -> 2 -> 3 -> 4
5+
# and you are given the third node with value 3, the linked list should become
6+
# 1 -> 2 -> 4 after calling your function.
87

98

109
# Definition for singly-linked list.

algorithms/different_ways_to_add_parentheses.rb

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# https://leetcode.com/problems/different-ways-to-add-parentheses/
22
#
3-
# Given a string of numbers and operators, return all possible results
4-
# from computing all the different possible ways to group numbers and
5-
# operators. The valid operators are +, - and *.
3+
# Given a string of numbers and operators, return all possible results from
4+
# computing all the different possible ways to group numbers and operators.
5+
# The valid operators are +, - and *.
66
#
77
# Example 1
88
#
@@ -24,6 +24,11 @@
2424
# (((2*3)-4)*5) = 10
2525
#
2626
# Output: [-34, -14, -10, -10, 10]
27+
#
28+
# Credits:
29+
#
30+
# Special thanks to @mithmatt for adding this problem and creating all
31+
# test cases.
2732

2833

2934
# @param {String} input

algorithms/distinct_subsequences.rb

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# https://leetcode.com/problems/distinct-subsequences/
22
#
3-
# Given a string S and a string T, count the number of distinct
4-
# subsequences of T in S. A subsequence of a string is a new string
5-
# which is formed from the original string by deleting some (can be none)
6-
# of the characters without disturbing the relative positions of
7-
# the remaining characters. (ie, "ACE" is a subsequence of "ABCDE"
8-
# while "AEC" is not).
3+
# Given a string S and a string T, count the number of distinct subsequences
4+
# of T in S. A subsequence of a string is a new string which is formed from
5+
# the original string by deleting some (can be none) of the characters without
6+
# disturbing the relative positions of the remaining characters. (ie, "ACE" is
7+
# a subsequence of "ABCDE" while "AEC" is not).
98
#
109
# Here is an example: S = "rabbbit", T = "rabbit", Return 3.
1110

algorithms/divide_two_integers.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# https://leetcode.com/problems/divide-two-integers/
22
#
3-
# Divide two integers without using multiplication, division and
4-
# mod operator. If it is overflow, return MAX_INT.
3+
# Divide two integers without using multiplication, division and mod operator.
4+
# If it is overflow, return MAX_INT.
55

66

77
# Limits on Integer Constants

algorithms/dungeon_game.rb

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
# https://leetcode.com/problems/dungeon-game/
22
#
33
# The demons had captured the princess (P) and imprisoned her in the
4-
# bottom-right corner of a dungeon. The dungeon consists of M x N
5-
# rooms laid out in a 2D grid. Our valiant knight (K) was initially
6-
# positioned in the top-left room and must fight his way through the
7-
# dungeon to rescue the princess.
4+
# bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid
5+
# out in a 2D grid. Our valiant knight (K) was initially positioned in the
6+
# top-left room and must fight his way through the dungeon to rescue the
7+
# princess.
88
#
9-
# The knight has an initial health point represented by a positive
10-
# integer. If at any point his health point drops to 0 or below,
11-
# he dies immediately.
9+
# The knight has an initial health point represented by a positive integer. If
10+
# at any point his health point drops to 0 or below, he dies immediately.
1211
#
13-
# Some of the rooms are guarded by demons, so the knight loses health
14-
# (negative integers) upon entering these rooms; other rooms are
15-
# either empty (0's) or contain magic orbs that increase the knight's
16-
# health (positive integers).
12+
# Some of the rooms are guarded by demons, so the knight loses health (negative
13+
# integers) upon entering these rooms; other rooms are either empty (0's) or
14+
# contain magic orbs that increase the knight's health (positive integers).
1715
#
18-
# In order to reach the princess as quickly as possible, the knight
19-
# decides to move only rightward or downward in each step.
16+
# In order to reach the princess as quickly as possible, the knight decides to
17+
# move only rightward or downward in each step.
2018
#
21-
# Write a function to determine the knight's minimum initial health
22-
# so that he is able to rescue the princess.
19+
# Write a function to determine the knight's minimum initial health so that he
20+
# is able to rescue the princess.
2321
#
24-
# For example, given the dungeon below, the initial health of the
25-
# knight must be at least 7 if he follows the optimal path
26-
# RIGHT -> RIGHT -> DOWN -> DOWN.
22+
# For example, given the dungeon below, the initial health of the knight must
23+
# be at least 7 if he follows the optimal path RIGHT -> RIGHT -> DOWN -> DOWN.
2724
#
2825
# +-------+-------+-------+
2926
# | | | |
@@ -42,9 +39,13 @@
4239
# Notes:
4340
#
4441
# + The knight's health has no upper bound.
45-
# + Any room can contain threats or power-ups, even the first room
46-
# the knight enters and the bottom-right room where the princess
47-
# is imprisoned.
42+
# + Any room can contain threats or power-ups, even the first room the
43+
# knight enters and the bottom-right room where the princess is imprisoned.
44+
#
45+
# Credits:
46+
#
47+
# Special thanks to @stellari for adding this problem and creating all
48+
# test cases.
4849

4950

5051
# @param {Integer[][]} dungeon

0 commit comments

Comments
 (0)