Skip to content

Commit 3d80a07

Browse files
author
0x01f7
committed
style: comment
1 parent eaf792a commit 3d80a07

File tree

5 files changed

+42
-30
lines changed

5 files changed

+42
-30
lines changed

algorithms/next_permutation.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# https://leetcode.com/problems/next-permutation/
22
#
33
# Implement next permutation, which rearranges numbers into the
4-
# lexicographically next greater permutation of numbers. If
5-
# such arrangement is not possible, it must rearrange it as the
6-
# lowest possible order (ie, sorted in ascending order). The
7-
# replacement must be in-place, do not allocate extra memory.
8-
# Here are some examples. Inputs are in the left-hand column
9-
# and its corresponding outputs are in the right-hand column.
4+
# lexicographically next greater permutation of numbers. If such arrangement
5+
# is not possible, it must rearrange it as the lowest possible order (ie,
6+
# sorted in ascending order). The replacement must be in-place, do not
7+
# allocate extra memory. Here are some examples. Inputs are in the left-hand
8+
# column and its corresponding outputs are in the right-hand column.
109
#
1110
# 1,2,3 -> 1,3,2
1211
# 3,2,1 -> 1,2,3

algorithms/nim_game.rb

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
# https://leetcode.com/problems/nim-game/
22
#
3-
# You are playing the following Nim Game with your friend: There is a heap
4-
# of stones on the table, each time one of you take turns to remove 1 to 3
5-
# stones. The one who removes the last stone will be the winner. You will
6-
# take the first turn to remove the stones.
3+
# You are playing the following Nim Game with your friend: There is a heap of
4+
# stones on the table, each time one of you take turns to remove 1 to 3 stones.
5+
# The one who removes the last stone will be the winner. You will take the
6+
# first turn to remove the stones.
77
#
8-
# Both of you are very clever and have optimal strategies for the game.
9-
# Write a function to determine whether you can win the game given the
10-
# number of stones in the heap.
8+
# Both of you are very clever and have optimal strategies for the game. Write
9+
# a function to determine whether you can win the game given the number of
10+
# stones in the heap.
1111
#
12-
# For example, if there are 4 stones in the heap, then you will never win
13-
# the game: no matter 1, 2, or 3 stones you remove, the last stone will
14-
# always be removed by your friend.
12+
# For example, if there are 4 stones in the heap, then you will never win the
13+
# game: no matter 1, 2, or 3 stones you remove, the last stone will always be
14+
# removed by your friend.
15+
#
16+
# Credits:
17+
#
18+
# Special thanks to @jianchao.li.fighter for adding this problem and
19+
# creating all test cases.
1520

1621

1722
# @param {Integer} n

algorithms/number_of_1_bits.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# https://leetcode.com/problems/number-of-1-bits/
22
#
3-
# Write a function that takes an unsigned integer
4-
# and returns the number of ’1' bits it has (also
5-
# known as the Hamming weight).
3+
# Write a function that takes an unsigned integer and returns the number of '1'
4+
# bits it has (also known as the Hamming weight).
65
#
7-
# For example, the 32-bit integer ’11' has binary
8-
# representation 00000000000000000000000000001011,
9-
# so the function should return 3.
6+
# For example, the 32-bit integer '11' has binary representation
7+
# 00000000000000000000000000001011, so the function should return 3.
8+
#
9+
# Credits:
10+
#
11+
# Special thanks to @ts for adding this problem and creating all test
12+
# cases.
1013

1114

1215
# @param {Integer} n, a positive integer

algorithms/number_of_digit_one.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# https://leetcode.com/problems/number-of-digit-one/
22
#
3-
# Given an integer n, count the total number of digit 1 appearing
4-
# in all non-negative integers less than or equal to n.
3+
# Given an integer n, count the total number of digit 1 appearing in all
4+
# non-negative integers less than or equal to n.
55
#
66
# For example:
77
#
8-
# Given n = 13, Return 6, because digit 1 occurred in the
9-
# following numbers: 1, 10, 11, 12, 13.
8+
# Given n = 13, Return 6, because digit 1 occurred in the following
9+
# numbers: 1, 10, 11, 12, 13.
1010

1111

1212
# @param {Integer} n

algorithms/number_of_islands.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# https://leetcode.com/problems/number-of-islands/
22
#
3-
# Given a 2d grid map of '1's (land) and '0's (water), count the number
4-
# of islands. An island is surrounded by water and is formed by connecting
5-
# adjacent lands horizontally or vertically. You may assume all four edges
6-
# of the grid are all surrounded by water.
3+
# Given a 2d grid map of '1's (land) and '0's (water), count the number of
4+
# islands. An island is surrounded by water and is formed by connecting
5+
# adjacent lands horizontally or vertically. You may assume all four edges of
6+
# the grid are all surrounded by water.
77
#
88
# Example 1:
99
#
@@ -22,6 +22,11 @@
2222
# 00011
2323
#
2424
# Answer: 3
25+
#
26+
# Credits:
27+
#
28+
# Special thanks to @mithmatt for adding this problem and creating all
29+
# test cases.
2530

2631

2732
# @param {Character[][]} grid

0 commit comments

Comments
 (0)