diff --git a/solution/0000-0099/0080.Remove Duplicates from Sorted Array II/README.md b/solution/0000-0099/0080.Remove Duplicates from Sorted Array II/README.md index ae842e6011937..e0031396abd37 100644 --- a/solution/0000-0099/0080.Remove Duplicates from Sorted Array II/README.md +++ b/solution/0000-0099/0080.Remove Duplicates from Sorted Array II/README.md @@ -46,7 +46,7 @@ for (int i = 0; i < len; i++) {
输入:nums = [0,0,1,1,1,1,2,3,3] 输出:7, nums = [0,0,1,1,2,3,3] -解释:函数应返回新长度 length =7
, 并且原数组的前五个元素被修改为0, 0, 1, 1, 2, 3, 3
。不需要考虑数组中超出新长度后面的元素。 +解释:函数应返回新长度 length =7
, 并且原数组的前七个元素被修改为0, 0, 1, 1, 2, 3, 3
。不需要考虑数组中超出新长度后面的元素。
diff --git a/solution/0100-0199/0139.Word Break/README.md b/solution/0100-0199/0139.Word Break/README.md index a31e9b0407a0a..09ad1dae37f9f 100644 --- a/solution/0100-0199/0139.Word Break/README.md +++ b/solution/0100-0199/0139.Word Break/README.md @@ -6,7 +6,7 @@ -
给你一个字符串 s
和一个字符串列表 wordDict
作为字典。请你判断是否可以利用字典中出现的单词拼接出 s
。
给你一个字符串 s
和一个字符串列表 wordDict
作为字典。如果可以利用字典中出现的一个或多个单词拼接出 s
则返回 true
。
注意:不要求字典中出现的单词全部都使用,并且字典中的单词可以重复使用。
diff --git a/solution/0100-0199/0153.Find Minimum in Rotated Sorted Array/README.md b/solution/0100-0199/0153.Find Minimum in Rotated Sorted Array/README.md index 95be27a3a377a..5ae7fec9de74c 100644 --- a/solution/0100-0199/0153.Find Minimum in Rotated Sorted Array/README.md +++ b/solution/0100-0199/0153.Find Minimum in Rotated Sorted Array/README.md @@ -34,7 +34,7 @@输入:nums = [4,5,6,7,0,1,2] 输出:0 -解释:原数组为 [0,1,2,4,5,6,7] ,旋转 4 次得到输入数组。 +解释:原数组为 [0,1,2,4,5,6,7] ,旋转 3 次得到输入数组。
示例 3:
diff --git a/solution/0300-0399/0320.Generalized Abbreviation/README.md b/solution/0300-0399/0320.Generalized Abbreviation/README.md index 914b3673a3a68..7b3378273c9d9 100644 --- a/solution/0300-0399/0320.Generalized Abbreviation/README.md +++ b/solution/0300-0399/0320.Generalized Abbreviation/README.md @@ -10,6 +10,7 @@"abcde"
可以缩写为:
+
"a3e"
("bcd"
变为 "3"
)"1bcd1"
("a"
和 "e"
都变为 "1"
)"22de"
("ab"
变为 "2"
, "bc"
变为 "2"
) 是无效的,因为被选择的字符串是重叠的给你一个字符串 word
,返回 一个由 word
的所有可能 广义缩写词 组成的列表 。按 任意顺序 返回答案。
"abcde"
can be abbreviated into:
+
"a3e"
("bcd"
turned into "3"
)"1bcd1"
("a"
and "e"
both turned into "1"
)"22de"
("ab"
turned into "2"
and "bc"
turned into "2"
) is invalid as the substring chosen overlap.Given a string word
, return a list of all the possible generalized abbreviations of word
. Return the answer in any order.
示例 2:
@@ -59,9 +59,9 @@ 输出:1 解释:有两个可能的数字 1 和 2 。 - 你可以先猜 1 。 - - 如果这是我选中的数字,你的总费用为 0 。否则,你需要支付 1 。 - - 如果我的数字更大,那么这个数字一定是 2 。你猜测数字为 2 并赢得游戏,总费用为 1 。 -最糟糕的情况下,你需要支付 1 。 + - 如果这是我选中的数字,你的总费用为 $0 。否则,你需要支付 $1 。 + - 如果我的数字更大,那么这个数字一定是 2 。你猜测数字为 2 并赢得游戏,总费用为 $1 。 +最糟糕的情况下,你需要支付 $1 。diff --git a/solution/0300-0399/0375.Guess Number Higher or Lower II/README_EN.md b/solution/0300-0399/0375.Guess Number Higher or Lower II/README_EN.md index 44f2c81c66fc0..43febb85456f8 100644 --- a/solution/0300-0399/0375.Guess Number Higher or Lower II/README_EN.md +++ b/solution/0300-0399/0375.Guess Number Higher or Lower II/README_EN.md @@ -24,21 +24,21 @@ Output: 16 Explanation: The winning strategy is as follows: - The range is [1,10]. Guess 7. - - If this is my number, your total is 0. Otherwise, you pay 7. + - If this is my number, your total is $0. Otherwise, you pay $7. - If my number is higher, the range is [8,10]. Guess 9. - - If this is my number, your total is 7. Otherwise, you pay 9. - - If my number is higher, it must be 10. Guess 10. Your total is 7 + 9 = 16. - - If my number is lower, it must be 8. Guess 8. Your total is 7 + 9 = 16. + - If this is my number, your total is $7. Otherwise, you pay $9. + - If my number is higher, it must be 10. Guess 10. Your total is $7 + $9 = $16. + - If my number is lower, it must be 8. Guess 8. Your total is $7 + $9 = $16. - If my number is lower, the range is [1,6]. Guess 3. - - If this is my number, your total is 7. Otherwise, you pay 3. + - If this is my number, your total is $7. Otherwise, you pay $3. - If my number is higher, the range is [4,6]. Guess 5. - - If this is my number, your total is 7 + 3 = 10. Otherwise, you pay 5. - - If my number is higher, it must be 6. Guess 6. Your total is 7 + 3 + 5 = 15. - - If my number is lower, it must be 4. Guess 4. Your total is 7 + 3 + 5 = 15. + - If this is my number, your total is $7 + $3 = $10. Otherwise, you pay $5. + - If my number is higher, it must be 6. Guess 6. Your total is $7 + $3 + $5 = $15. + - If my number is lower, it must be 4. Guess 4. Your total is $7 + $3 + $5 = $15. - If my number is lower, the range is [1,2]. Guess 1. - - If this is my number, your total is 7 + 3 = 10. Otherwise, you pay 1. - - If my number is higher, it must be 2. Guess 2. Your total is 7 + 3 + 1 = 11. -The worst case in all these scenarios is that you pay 16. Hence, you only need 16 to guarantee a win. + - If this is my number, your total is $7 + $3 = $10. Otherwise, you pay $1. + - If my number is higher, it must be 2. Guess 2. Your total is $7 + $3 + $1 = $11. +The worst case in all these scenarios is that you pay $16. Hence, you only need $16 to guarantee a win.
Example 2:
@@ -56,9 +56,9 @@ The worst case in all these scenarios is that you pay 16. Hence, you only need 1 Output: 1 Explanation: There are two possible numbers, 1 and 2. - Guess 1. - - If this is my number, your total is 0. Otherwise, you pay 1. - - If my number is higher, it must be 2. Guess 2. Your total is 1. -The worst case is that you pay 1. + - If this is my number, your total is $0. Otherwise, you pay $1. + - If my number is higher, it must be 2. Guess 2. Your total is $1. +The worst case is that you pay $1.diff --git a/solution/0400-0499/0447.Number of Boomerangs/README.md b/solution/0400-0499/0447.Number of Boomerangs/README.md index 40a5f7ebfad88..f87cfddda226d 100644 --- a/solution/0400-0499/0447.Number of Boomerangs/README.md +++ b/solution/0400-0499/0447.Number of Boomerangs/README.md @@ -6,7 +6,7 @@ -
给定平面上 n
对 互不相同 的点 points
,其中 points[i] = [xi, yi]
。回旋镖 是由点 (i, j, k)
表示的元组 ,其中 i
和 j
之间的距离和 i
和 k
之间的欧式距离相等(需要考虑元组的顺序)。
给定平面上 n
对 互不相同 的点 points
,其中 points[i] = [xi, yi]
。回旋镖 是由点 (i, j, k)
表示的元组 ,其中 i
和 j
之间的欧式距离和 i
和 k
之间的欧式距离相等(需要考虑元组的顺序)。
返回平面上所有回旋镖的数量。
diff --git a/solution/0400-0499/0465.Optimal Account Balancing/README.md b/solution/0400-0499/0465.Optimal Account Balancing/README.md index c978d3cb80789..e059001f557f4 100644 --- a/solution/0400-0499/0465.Optimal Account Balancing/README.md +++ b/solution/0400-0499/0465.Optimal Account Balancing/README.md @@ -6,7 +6,7 @@ -给你一个表示交易的数组 transactions
,其中 transactions[i] = [fromi, toi, amounti]
表示 ID = fromi
的人给 ID = toi
的人共计 amounti
。
给你一个表示交易的数组 transactions
,其中 transactions[i] = [fromi, toi, amounti]
表示 ID = fromi
的人给 ID = toi
的人共计 amounti $
。
请你计算并返回还清所有债务的最小交易笔数。
@@ -18,9 +18,9 @@ 输入:transactions = [[0,1,10],[2,0,5]] 输出:2 解释: -#0 给 #1 10 。 -#2 给 #0 5 。 -需要进行两笔交易。一种结清债务的方式是 #1 给 #0 和 #2 各 5 。 +#0 给 #1 $10 。 +#2 给 #0 $5 。 +需要进行两笔交易。一种结清债务的方式是 #1 给 #0 和 #2 各 $5 。示例 2:
@@ -28,11 +28,11 @@ 输入:transactions = [[0,1,10],[1,0,1],[1,2,5],[2,0,5]] 输出:1 解释: -#0 给 #1 10 。 -#1 给 #0 1 。 -#1 给 #2 5 。 -#2 给 #0 5 。 -因此,#1 只需要给 #0 4 ,所有的债务即可还清。 +#0 给 #1 $10 。 +#1 给 #0 $1 。 +#1 给 #2 $5 。 +#2 给 #0 $5 。 +因此,#1 只需要给 #0 $4 ,所有的债务即可还清。diff --git a/solution/0400-0499/0465.Optimal Account Balancing/README_EN.md b/solution/0400-0499/0465.Optimal Account Balancing/README_EN.md index a7f757fc4189c..923c4e112d7ec 100644 --- a/solution/0400-0499/0465.Optimal Account Balancing/README_EN.md +++ b/solution/0400-0499/0465.Optimal Account Balancing/README_EN.md @@ -4,7 +4,7 @@ ## Description -
You are given an array of transactions transactions
where transactions[i] = [fromi, toi, amounti]
indicates that the person with ID = fromi
gave amounti
to the person with ID = toi
.
You are given an array of transactions transactions
where transactions[i] = [fromi, toi, amounti]
indicates that the person with ID = fromi
gave amounti $
to the person with ID = toi
.
Return the minimum number of transactions required to settle the debt.
@@ -15,9 +15,9 @@ Input: transactions = [[0,1,10],[2,0,5]] Output: 2 Explanation: -Person #0 gave person #1 10. -Person #2 gave person #0 5. -Two transactions are needed. One way to settle the debt is person #1 pays person #0 and #2 5 each. +Person #0 gave person #1 $10. +Person #2 gave person #0 $5. +Two transactions are needed. One way to settle the debt is person #1 pays person #0 and #2 $5 each.Example 2:
@@ -26,11 +26,11 @@ Two transactions are needed. One way to settle the debt is person #1 pays person Input: transactions = [[0,1,10],[1,0,1],[1,2,5],[2,0,5]] Output: 1 Explanation: -Person #0 gave person #1 10. -Person #1 gave person #0 1. -Person #1 gave person #2 5. -Person #2 gave person #0 5. -Therefore, person #1 only need to give person #0 4, and all debt is settled. +Person #0 gave person #1 $10. +Person #1 gave person #0 $1. +Person #1 gave person #2 $5. +Person #2 gave person #0 $5. +Therefore, person #1 only need to give person #0 $4, and all debt is settled.diff --git a/solution/0500-0599/0549.Binary Tree Longest Consecutive Sequence II/README.md b/solution/0500-0599/0549.Binary Tree Longest Consecutive Sequence II/README.md index 082cc85e8abfd..2c83044edb8b8 100644 --- a/solution/0500-0599/0549.Binary Tree Longest Consecutive Sequence II/README.md +++ b/solution/0500-0599/0549.Binary Tree Longest Consecutive Sequence II/README.md @@ -1,4 +1,4 @@ -# [549. 二叉树中最长的连续序列](https://leetcode.cn/problems/binary-tree-longest-consecutive-sequence-ii) +# [549. 二叉树最长连续序列 II](https://leetcode.cn/problems/binary-tree-longest-consecutive-sequence-ii) [English Version](/solution/0500-0599/0549.Binary%20Tree%20Longest%20Consecutive%20Sequence%20II/README_EN.md) diff --git a/solution/0600-0699/0638.Shopping Offers/README_EN.md b/solution/0600-0699/0638.Shopping Offers/README_EN.md index b401b5e3aa1dd..44c0dc4bd9761 100644 --- a/solution/0600-0699/0638.Shopping Offers/README_EN.md +++ b/solution/0600-0699/0638.Shopping Offers/README_EN.md @@ -18,10 +18,10 @@
Input: price = [2,5], special = [[3,0,5],[1,2,10]], needs = [3,2] Output: 14 -Explanation: There are two kinds of items, A and B. Their prices are 2 and 5 respectively. -In special offer 1, you can pay 5 for 3A and 0B -In special offer 2, you can pay 10 for 1A and 2B. -You need to buy 3A and 2B, so you may pay 10 for 1A and 2B (special offer #2), and 4 for 2A. +Explanation: There are two kinds of items, A and B. Their prices are $2 and $5 respectively. +In special offer 1, you can pay $5 for 3A and 0B +In special offer 2, you can pay $10 for 1A and 2B. +You need to buy 3A and 2B, so you may pay $10 for 1A and 2B (special offer #2), and $4 for 2A.
Example 2:
@@ -29,10 +29,10 @@ You need to buy 3A and 2B, so you may pay 10 for 1A and 2B (special offer #2), aInput: price = [2,3,4], special = [[1,1,0,4],[2,2,1,9]], needs = [1,2,1] Output: 11 -Explanation: The price of A is 2, and 3 for B, 4 for C. -You may pay 4 for 1A and 1B, and 9 for 2A ,2B and 1C. -You need to buy 1A ,2B and 1C, so you may pay 4 for 1A and 1B (special offer #1), and 3 for 1B, 4 for 1C. -You cannot add more items, though only 9 for 2A ,2B and 1C. +Explanation: The price of A is $2, and $3 for B, $4 for C. +You may pay $4 for 1A and 1B, and $9 for 2A ,2B and 1C. +You need to buy 1A ,2B and 1C, so you may pay $4 for 1A and 1B (special offer #1), and $3 for 1B, $4 for 1C. +You cannot add more items, though only $9 for 2A ,2B and 1C.
diff --git a/solution/0600-0699/0679.24 Game/README.md b/solution/0600-0699/0679.24 Game/README.md index 8d35008eaf38d..eb51f1bb4d639 100644 --- a/solution/0600-0699/0679.24 Game/README.md +++ b/solution/0600-0699/0679.24 Game/README.md @@ -12,6 +12,7 @@
'/'
表示实数除法,而不是整数除法。
+
4 /(1 - 2 / 3)= 4 /(1 / 3)= 12
。cards =[1,2,1,2]
,则表达式 “12 + 12”
无效。如果可以得到这样的表达式,其计算结果为 24
,则返回 true
,否则返回 false
。
'/'
represents real division, not integer division.
+
4 / (1 - 2 / 3) = 4 / (1 / 3) = 12
.cards = [1, 2, 1, 2]
, the expression "12 + 12"
is not valid.Return true
if you can get such expression that evaluates to 24
, and false
otherwise.
x
.
+
x
.Return the sum of all the scores on the record after applying all the operations.
diff --git a/solution/0700-0799/0753.Cracking the Safe/README_EN.md b/solution/0700-0799/0753.Cracking the Safe/README_EN.md index 682c527424f33..10f62faa347a8 100644 --- a/solution/0700-0799/0753.Cracking the Safe/README_EN.md +++ b/solution/0700-0799/0753.Cracking the Safe/README_EN.md @@ -10,6 +10,7 @@"345"
and you enter in "012345"
:
+
0
, the most recent 3
digits is "0"
, which is incorrect.1
, the most recent 3
digits is "01"
, which is incorrect.5
, the most recent 3
digits is "345"
, which is correct and the safe unlocks.Return any string of minimum length that will unlock the safe at some point of entering it.
@@ -42,7 +44,7 @@ - "01" is typed in starting from the 1st digit. - "10" is typed in starting from the 3rd digit. - "11" is typed in starting from the 2nd digit. -Thus "01100" will unlock the safe. "01100", "10011", and "11001" would also unlock the safe. +Thus "01100" will unlock the safe. "10011", and "11001" would also unlock the safe.diff --git a/solution/0800-0899/0818.Race Car/README_EN.md b/solution/0800-0899/0818.Race Car/README_EN.md index fa23005bce7c9..41df8140a4888 100644 --- a/solution/0800-0899/0818.Race Car/README_EN.md +++ b/solution/0800-0899/0818.Race Car/README_EN.md @@ -8,6 +8,7 @@
'A'
, your car does the following:
+
position += speed
speed *= 2
speed = 1
For example, after commands "AAR"
, your car goes to positions 0 --> 1 --> 3 --> 3
, and your speed goes to 1 --> 2 --> 4 --> -1
.
'a'
, 'e'
, 'i'
, 'o'
, 'u'
),在单词后添加"ma"
。
+
"apple"
变为 "applema"
。"a"
,在第二个单词后添加 "aa"
,以此类推。返回将 sentence
转换为山羊拉丁文后的句子。
'a'
, 'e'
, 'i'
, 'o'
, or 'u'
), append "ma"
to the end of the word.
+
"apple"
becomes "applema"
."a"
added to the end, the second word gets "aa"
added to the end, and so on.Return the final sentence representing the conversion from sentence to Goat Latin.
diff --git a/solution/0800-0899/0860.Lemonade Change/README_EN.md b/solution/0800-0899/0860.Lemonade Change/README_EN.md index c134066f49bba..92fd26ae78175 100644 --- a/solution/0800-0899/0860.Lemonade Change/README_EN.md +++ b/solution/0800-0899/0860.Lemonade Change/README_EN.md @@ -4,7 +4,7 @@ ## Description -At a lemonade stand, each lemonade costs 5
. Customers are standing in a queue to buy from you and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a 5
, 10
, or 20
bill. You must provide the correct change to each customer so that the net transaction is that the customer pays 5
.
At a lemonade stand, each lemonade costs $5
. Customers are standing in a queue to buy from you and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a $5
, $10
, or $20
bill. You must provide the correct change to each customer so that the net transaction is that the customer pays $5
.
Note that you do not have any change in hand at first.
@@ -17,9 +17,9 @@ Input: bills = [5,5,5,10,20] Output: true Explanation: -From the first 3 customers, we collect three 5 bills in order. -From the fourth customer, we collect a 10 bill and give back a 5. -From the fifth customer, we give a 10 bill and a 5 bill. +From the first 3 customers, we collect three $5 bills in order. +From the fourth customer, we collect a $10 bill and give back a $5. +From the fifth customer, we give a $10 bill and a $5 bill. Since all customers got correct change, we output true. @@ -29,9 +29,9 @@ Since all customers got correct change, we output true. Input: bills = [5,5,10,10,20] Output: false Explanation: -From the first two customers in order, we collect two 5 bills. -For the next two customers in order, we collect a 10 bill and give back a 5 bill. -For the last customer, we can not give the change of 15 back because we only have two 10 bills. +From the first two customers in order, we collect two $5 bills. +For the next two customers in order, we collect a $10 bill and give back a $5 bill. +For the last customer, we can not give the change of $15 back because we only have two $10 bills. Since not every customer received the correct change, the answer is false. diff --git a/solution/0900-0999/0909.Snakes and Ladders/README.md b/solution/0900-0999/0909.Snakes and Ladders/README.md index 8427632bd9832..fa5f15d4e158f 100644 --- a/solution/0900-0999/0909.Snakes and Ladders/README.md +++ b/solution/0900-0999/0909.Snakes and Ladders/README.md @@ -14,12 +14,14 @@next
,目标方格的编号符合范围 [curr + 1, min(curr + 6, n2)]
。
+
next
处存在蛇或梯子,那么玩家会传送到蛇或梯子的目的地。否则,玩家传送到目标方格 next
。 n2
的方格时,游戏结束。r
行 c
列的棋盘,按前述方法编号,棋盘格中可能存在 “蛇” 或 “梯子”;如果 board[r][c] != -1
,那个蛇或梯子的目的地将会是 board[r][c]
。编号为 1
和 n2
的方格上没有蛇或梯子。
next
with a label in the range [curr + 1, min(curr + 6, n2)]
.
+
next
has a snake or ladder, you must move to the destination of that snake or ladder. Otherwise, you move to next
.n2
.A board square on row r
and column c
has a snake or ladder if board[r][c] != -1
. The destination of that snake or ladder is board[r][c]
. Squares 1
and n2
do not have a snake or ladder.
A subarray is a contiguous part of the array.
-
Example 1:
- Input: nums = [1,0,1,0,1], goal = 2 - Output: 4 - Explanation: The 4 subarrays are bolded and underlined below: - [1,0,1,0,1] - [1,0,1,0,1] - [1,0,1,0,1] - [1,0,1,0,1] -
Example 2:
- Input: nums = [0,0,0,0,0], goal = 0 - Output: 15 -
-
Constraints:
1 <= nums.length <= 3 * 104
nums[i]
is either 0
or 1
.0 <= goal <= nums.length
1 <= nums.length <= 3 * 104
nums[i]
is either 0
or 1
.0 <= goal <= nums.length
stamp = "abc"
and target = "abcba"
, then s
is "?????"
initially. In one turn you can:
+
stamp
at index 0
of s
to obtain "abc??"
,stamp
at index 1
of s
to obtain "?abc?"
, orstamp
at index 2
of s
to obtain "??abc"
.stamp
must be fully contained in the boundaries of s
in order to stamp (i.e., you cannot place stamp
at index 3
of s
).We want to convert s
to target
using at most 10 * target.length
turns.
<IntegerPart>
+
0
,12
和 123
0.1(6)
, 1.(9)
, 123.00(1212)
十进制展开的重复部分通常在一对圆括号内表示。例如:
diff --git a/solution/0900-0999/0972.Equal Rational Numbers/README_EN.md b/solution/0900-0999/0972.Equal Rational Numbers/README_EN.md index 82b6632855551..42c2d3d91c8ac 100644 --- a/solution/0900-0999/0972.Equal Rational Numbers/README_EN.md +++ b/solution/0900-0999/0972.Equal Rational Numbers/README_EN.md @@ -10,6 +10,7 @@<IntegerPart>
+
12
, 0
, and 123
.0.1(6)
, 1.(9)
, 123.00(1212)
.The repeating portion of a decimal expansion is conventionally denoted within a pair of round brackets. For example:
diff --git a/solution/0900-0999/0978.Longest Turbulent Subarray/README.md b/solution/0900-0999/0978.Longest Turbulent Subarray/README.md index ff52e832525d9..ed1fa61338a64 100644 --- a/solution/0900-0999/0978.Longest Turbulent Subarray/README.md +++ b/solution/0900-0999/0978.Longest Turbulent Subarray/README.md @@ -14,6 +14,7 @@i <= k < j
:
+
k
为奇数时, A[k] > A[k+1]
,且k
为偶数时,A[k] < A[k+1]
;k
为奇数时, A[k] < A[k+1]
。diff --git a/solution/0900-0999/0978.Longest Turbulent Subarray/README_EN.md b/solution/0900-0999/0978.Longest Turbulent Subarray/README_EN.md index e650fdf9217ac..013e08728cc7b 100644 --- a/solution/0900-0999/0978.Longest Turbulent Subarray/README_EN.md +++ b/solution/0900-0999/0978.Longest Turbulent Subarray/README_EN.md @@ -12,6 +12,7 @@
i <= k < j
:
+
arr[k] > arr[k + 1]
when k
is odd, andarr[k] < arr[k + 1]
when k
is even.arr[k] < arr[k + 1]
when k
is odd.diff --git a/solution/0900-0999/0983.Minimum Cost For Tickets/README.md b/solution/0900-0999/0983.Minimum Cost For Tickets/README.md index 207580002c7f8..08b9c078be027 100644 --- a/solution/0900-0999/0983.Minimum Cost For Tickets/README.md +++ b/solution/0900-0999/0983.Minimum Cost For Tickets/README.md @@ -29,10 +29,10 @@ 输出:11 解释: 例如,这里有一种购买通行证的方法,可以让你完成你的旅行计划: -在第 1 天,你花了 costs[0] = 2 买了一张为期 1 天的通行证,它将在第 1 天生效。 -在第 3 天,你花了 costs[1] = 7 买了一张为期 7 天的通行证,它将在第 3, 4, ..., 9 天生效。 -在第 20 天,你花了 costs[0] = 2 买了一张为期 1 天的通行证,它将在第 20 天生效。 -你总共花了 11,并完成了你计划的每一天旅行。 +在第 1 天,你花了 costs[0] = $2 买了一张为期 1 天的通行证,它将在第 1 天生效。 +在第 3 天,你花了 costs[1] = $7 买了一张为期 7 天的通行证,它将在第 3, 4, ..., 9 天生效。 +在第 20 天,你花了 costs[0] = $2 买了一张为期 1 天的通行证,它将在第 20 天生效。 +你总共花了 $11,并完成了你计划的每一天旅行。
示例 2:
@@ -42,9 +42,9 @@ 输出:17 解释: 例如,这里有一种购买通行证的方法,可以让你完成你的旅行计划: -在第 1 天,你花了 costs[2] = 15 买了一张为期 30 天的通行证,它将在第 1, 2, ..., 30 天生效。 -在第 31 天,你花了 costs[0] = 2 买了一张为期 1 天的通行证,它将在第 31 天生效。 -你总共花了 17,并完成了你计划的每一天旅行。 +在第 1 天,你花了 costs[2] = $15 买了一张为期 30 天的通行证,它将在第 1, 2, ..., 30 天生效。 +在第 31 天,你花了 costs[0] = $2 买了一张为期 1 天的通行证,它将在第 31 天生效。 +你总共花了 $17,并完成了你计划的每一天旅行。diff --git a/solution/0900-0999/0983.Minimum Cost For Tickets/README_EN.md b/solution/0900-0999/0983.Minimum Cost For Tickets/README_EN.md index e08426c400393..01ea92c16f873 100644 --- a/solution/0900-0999/0983.Minimum Cost For Tickets/README_EN.md +++ b/solution/0900-0999/0983.Minimum Cost For Tickets/README_EN.md @@ -29,10 +29,10 @@ Input: days = [1,4,6,7,8,20], costs = [2,7,15] Output: 11 Explanation: For example, here is one way to buy passes that lets you travel your travel plan: -On day 1, you bought a 1-day pass for costs[0] = 2, which covered day 1. -On day 3, you bought a 7-day pass for costs[1] = 7, which covered days 3, 4, ..., 9. -On day 20, you bought a 1-day pass for costs[0] = 2, which covered day 20. -In total, you spent 11 and covered all the days of your travel. +On day 1, you bought a 1-day pass for costs[0] = $2, which covered day 1. +On day 3, you bought a 7-day pass for costs[1] = $7, which covered days 3, 4, ..., 9. +On day 20, you bought a 1-day pass for costs[0] = $2, which covered day 20. +In total, you spent $11 and covered all the days of your travel.
Example 2:
@@ -41,9 +41,9 @@ In total, you spent 11 and covered all the days of your travel. Input: days = [1,2,3,4,5,6,7,8,9,10,30,31], costs = [2,7,15] Output: 17 Explanation: For example, here is one way to buy passes that lets you travel your travel plan: -On day 1, you bought a 30-day pass for costs[2] = 15 which covered days 1, 2, ..., 30. -On day 31, you bought a 1-day pass for costs[0] = 2 which covered day 31. -In total, you spent 17 and covered all the days of your travel. +On day 1, you bought a 30-day pass for costs[2] = $15 which covered days 1, 2, ..., 30. +On day 31, you bought a 1-day pass for costs[0] = $2 which covered day 31. +In total, you spent $17 and covered all the days of your travel.diff --git a/solution/0900-0999/0994.Rotting Oranges/README.md b/solution/0900-0999/0994.Rotting Oranges/README.md index 3ef2d55ad1cfd..807de0548dcaa 100644 --- a/solution/0900-0999/0994.Rotting Oranges/README.md +++ b/solution/0900-0999/0994.Rotting Oranges/README.md @@ -34,7 +34,7 @@
输入:grid = [[2,1,1],[0,1,1],[1,0,1]] 输出:-1 -解释:左下角的橘子(第 2 行, 第 0 列)永远不会腐烂,因为腐烂只会发生在 4 个正向上。 +解释:左下角的橘子(第 2 行, 第 0 列)永远不会腐烂,因为腐烂只会发生在 4 个方向上。
示例 3:
diff --git a/solution/1000-1099/1096.Brace Expansion II/README.md b/solution/1000-1099/1096.Brace Expansion II/README.md index dd7fd132ca58e..8406bb89dbbd8 100644 --- a/solution/1000-1099/1096.Brace Expansion II/README.md +++ b/solution/1000-1099/1096.Brace Expansion II/README.md @@ -12,6 +12,7 @@x
,那么表达式表示的字符串就只有 "x"
。R(x) = {x}
+
"a"
表示字符串 "a"
。"w"
就表示字符串 "w"
。A defanged IP address replaces every period "."
with "[.]"
.
-
Example 1:
-Input: address = "1.1.1.1" - Output: "1[.]1[.]1[.]1" -
Example 2:
-Input: address = "255.100.50.0" - Output: "255[.]100[.]50[.]0" --
-
Constraints:
address
is a valid IPv4 address.address
is a valid IPv4 address.-
平均活动 是指有特定 event_type
的具有该事件的所有公司的 occurences
的均值。
平均活动 是指有特定 event_type
的具有该事件的所有公司的 occurrences
的均值。
活跃业务 是指具有 多个 event_type
的业务,它们的 occurences
严格大于 该事件的平均活动次数。
活跃业务 是指具有 多个 event_type
的业务,它们的 occurrences
严格大于 该事件的平均活动次数。
写一个解决方案,找到所有 活跃业务。
@@ -39,17 +39,17 @@输入: Events table: -+-------------+------------+------------+ -| business_id | event_type | occurences | -+-------------+------------+------------+ -| 1 | reviews | 7 | -| 3 | reviews | 3 | -| 1 | ads | 11 | -| 2 | ads | 7 | -| 3 | ads | 6 | -| 1 | page views | 3 | -| 2 | page views | 12 | -+-------------+------------+------------+ ++-------------+------------+-------------+ +| business_id | event_type | occurrences | ++-------------+------------+-------------+ +| 1 | reviews | 7 | +| 3 | reviews | 3 | +| 1 | ads | 11 | +| 2 | ads | 7 | +| 3 | ads | 6 | +| 1 | page views | 3 | +| 2 | page views | 12 | ++-------------+------------+-------------+ 输出: +-------------+ | business_id | diff --git a/solution/1100-1199/1126.Active Businesses/README_EN.md b/solution/1100-1199/1126.Active Businesses/README_EN.md index b54402f395a0d..877d407f7be8f 100644 --- a/solution/1100-1199/1126.Active Businesses/README_EN.md +++ b/solution/1100-1199/1126.Active Businesses/README_EN.md @@ -12,23 +12,21 @@ +---------------+---------+ | business_id | int | | event_type | varchar | -| occurences | int | +| occurrences | int | +---------------+---------+ (business_id, event_type) is the primary key (combination of columns with unique values) of this table. Each row in the table logs the info that an event of some type occurred at some business for a number of times.-
- -
The average activity for a particular event_type
is the average occurences
across all companies that have this event.
The average activity for a particular event_type
is the average occurrences
across all companies that have this event.
An active business is a business that has more than one event_type
such that their occurences
is strictly greater than the average activity for that event.
An active business is a business that has more than one event_type
such that their occurrences
is strictly greater than the average activity for that event.
Write a solution to find all active businesses.
Return the result table in any order.
-The result format is in the following example.
+The result format is in the following example.
Example 1:
@@ -36,17 +34,17 @@ Each row in the table logs the info that an event of some type occurred at someInput: Events table: -+-------------+------------+------------+ -| business_id | event_type | occurences | -+-------------+------------+------------+ -| 1 | reviews | 7 | -| 3 | reviews | 3 | -| 1 | ads | 11 | -| 2 | ads | 7 | -| 3 | ads | 6 | -| 1 | page views | 3 | -| 2 | page views | 12 | -+-------------+------------+------------+ ++-------------+------------+-------------+ +| business_id | event_type | occurrences | ++-------------+------------+-------------+ +| 1 | reviews | 7 | +| 3 | reviews | 3 | +| 1 | ads | 11 | +| 2 | ads | 7 | +| 3 | ads | 6 | +| 1 | page views | 3 | +| 2 | page views | 12 | ++-------------+------------+-------------+ Output: +-------------+ | business_id | diff --git a/solution/1200-1299/1244.Design A Leaderboard/README.md b/solution/1200-1299/1244.Design A Leaderboard/README.md index 8d1e57e651177..3fafd3be1f5d1 100644 --- a/solution/1200-1299/1244.Design A Leaderboard/README.md +++ b/solution/1200-1299/1244.Design A Leaderboard/README.md @@ -12,6 +12,7 @@
addScore(playerId, score)
: +
- 假如参赛者已经在排行榜上,就给他的当前得分增加
score
点分值并更新排行。- 假如该参赛者不在排行榜上,就把他添加到榜单上,并且将分数设置为
@@ -19,6 +20,7 @@score
。top(K)
:返回前K
名参赛者的 得分总和。- +
reset(playerId)
:将指定参赛者的成绩清零(换句话说,将其从排行榜中删除)。题目保证在调用此函数前,该参赛者已有成绩,并且在榜单上。请注意,在初始状态下,排行榜是空的。
diff --git a/solution/1200-1299/1266.Minimum Time Visiting All Points/README_EN.md b/solution/1200-1299/1266.Minimum Time Visiting All Points/README_EN.md index 182dddf4a893f..40da73f11f88c 100644 --- a/solution/1200-1299/1266.Minimum Time Visiting All Points/README_EN.md +++ b/solution/1200-1299/1266.Minimum Time Visiting All Points/README_EN.md @@ -10,6 +10,7 @@
1
second, you can either:
+
diff --git a/solution/1200-1299/1275.Find Winner on a Tic Tac Toe Game/README.md b/solution/1200-1299/1275.Find Winner on a Tic Tac Toe Game/README.md index 507daeb0b2716..cc13efb6445e9 100644 --- a/solution/1200-1299/1275.Find Winner on a Tic Tac Toe Game/README.md +++ b/solution/1200-1299/1275.Find Winner on a Tic Tac Toe Game/README.md @@ -11,9 +11,9 @@
井字棋游戏的规则如下:
给你一个数组 moves
,其中每个元素是大小为 2
的另一个数组(元素分别对应网格的行和列),它按照 A 和 B 的行动顺序(先 A 后 B)记录了两人各自的棋子位置。
如果游戏存在获胜者(A 或 B),就返回该游戏的获胜者;如果游戏以平局结束,则返回 "Draw";如果仍会有行动(游戏未结束),则返回 "Pending"。
+如果游戏存在获胜者(A 或 B),就返回该游戏的获胜者;如果游戏以平局结束,则返回 "Draw";如果仍会有行动(游戏未结束),则返回 "Pending"。
你可以假设 moves
都 有效(遵循井字棋规则),网格最初是空的,A 将先行动。
示例 1:
-输入:moves = [[0,0],[2,0],[1,1],[2,1],[2,2]] -输出:"A" -解释:"A" 获胜,他总是先走。 -"X " "X " "X " "X " "X " -" " -> " " -> " X " -> " X " -> " X " -" " "O " "O " "OO " "OOX" ++输入:moves = [[0,0],[2,0],[1,1],[2,1],[2,2]] +输出:"A" +解释:"A" 获胜,他总是先走。 +"X " "X " "X " "X " "X " +" " -> " " -> " X " -> " X " -> " X " +" " "O " "O " "OO " "OOX"示例 2:
-输入:moves = [[0,0],[1,1],[0,1],[0,2],[1,0],[2,0]] -输出:"B" -解释:"B" 获胜。 -"X " "X " "XX " "XXO" "XXO" "XXO" -" " -> " O " -> " O " -> " O " -> "XO " -> "XO " -" " " " " " " " " " "O " ++输入:moves = [[0,0],[1,1],[0,1],[0,2],[1,0],[2,0]] +输出:"B" +解释:"B" 获胜。 +"X " "X " "XX " "XXO" "XXO" "XXO" +" " -> " O " -> " O " -> " O " -> "XO " -> "XO " +" " " " " " " " " " "O "示例 3:
-输入:moves = [[0,0],[1,1],[2,0],[1,0],[1,2],[2,1],[0,1],[0,2],[2,2]] -输出:"Draw" -输出:由于没有办法再行动,游戏以平局结束。 -"XXO" -"OOX" -"XOX" ++输入:moves = [[0,0],[1,1],[2,0],[1,0],[1,2],[2,1],[0,1],[0,2],[2,2]] +输出:"Draw" +解释:由于没有办法再行动,游戏以平局结束。 +"XXO" +"OOX" +"XOX"示例 4:
-输入:moves = [[0,0],[1,1]] -输出:"Pending" ++输入:moves = [[0,0],[1,1]] +输出:"Pending" 解释:游戏还没有结束。 -"X " -" O " -" " +"X " +" O " +" "diff --git a/solution/1300-1399/1396.Design Underground System/README.md b/solution/1300-1399/1396.Design Underground System/README.md index ae45e9efe3b01..08486012018ae 100644 --- a/solution/1300-1399/1396.Design Underground System/README.md +++ b/solution/1300-1399/1396.Design Underground System/README.md @@ -12,6 +12,7 @@
void checkIn(int id, string stationName, int t)
+
id
的乘客,在时间 t
,从 stationName
站进入getAverageTime
之前,至少有一名乘客从 startStation
站到达 endStation
站你可以假设对 checkIn
和 checkOut
方法的所有调用都是符合逻辑的。如果一名乘客在时间 t1
进站、时间 t2
出站,那么 t1 < t2
。所有时间都按时间顺序发生。
void checkIn(int id, string stationName, int t)
+
id
, checks in at the station stationName
at time t
.startStation
to endStation
before getAverageTime
is called.You may assume all calls to the checkIn
and checkOut
methods are consistent. If a customer checks in at time t1
then checks out at time t2
, then t1 < t2
. All events happen in chronological order.
@@ -50,26 +50,26 @@ price 是本产品的花销. | order_date | date | | quantity | int | +---------------+---------+ -order_id 是该表主键. +order_id 是该表具有唯一值的列. 该表包含消费者下单的信息. -customer_id 是买了数量为"quantity", id为"product_id"产品的消费者的 id. +customer_id 是买了数量为 "quantity", id 为 "product_id" 产品的消费者的 id. Order_date 是订单发货的日期, 格式为('YYYY-MM-DD').
-
写一个 SQL 查询,报告在 2020 年 6 月和 7 月 每个月至少花费 100 的客户的 customer_id 和 customer_name 。
+写一个解决方案,报告在 2020 年 6 月和 7 月 每个月至少花费 $100
的客户的 customer_id
和 customer_name
。
以任意顺序返回结果表.
+以 任意顺序 返回结果表.
-查询结果格式如下例所示。
+结果格式如下例所示。
示例 1:
-+解释: +Winston 在 2020 年 6 月花费了 $300(300 * 1), 在 7 月花费了 $100(10 * 1 + 45 * 2). +Jonathan 在 2020 年 6 月花费了 $600(300 * 2), 在 7 月花费了 $20(2 * 10). +Moustafa 在 2020 年 6 月花费了 $110 (10 * 2 + 45 * 2), 在 7 月花费了 $0. ## 解法 diff --git a/solution/1500-1599/1511.Customer Order Frequency/README_EN.md b/solution/1500-1599/1511.Customer Order Frequency/README_EN.md index f7e068da14f56..ccb6ea75dbf71 100644 --- a/solution/1500-1599/1511.Customer Order Frequency/README_EN.md +++ b/solution/1500-1599/1511.Customer Order Frequency/README_EN.md @@ -14,7 +14,7 @@ | name | varchar | | country | varchar | +---------------+---------+ -customer_id is the primary key for this table. +customer_id is the column with unique values for this table. This table contains information about the customers in the company. @@ -30,7 +30,7 @@ This table contains information about the customers in the company. | description | varchar | | price | int | +---------------+---------+ -product_id is the primary key for this table. +product_id is the column with unique values for this table. This table contains information on the products in the company. price is the product cost. @@ -49,7 +49,7 @@ price is the product cost. | order_date | date | | quantity | int | +---------------+---------+ -order_id is the primary key for this table. +order_id is the column with unique values for this table. This table contains information on customer orders. customer_id is the id of the customer who bought "quantity" products with id "product_id". Order_date is the date in format ('YYYY-MM-DD') when the order was shipped. @@ -57,11 +57,11 @@ Order_date is the date in format ('YYYY-MM-DD') when the order was shipp输入: -Customers table:
+输入: +Customers table:
+--------------+-----------+-------------+ | customer_id | name | country | +--------------+-----------+-------------+ @@ -77,7 +77,6 @@ Customers table: | 2 | Jonathan | Peru | | 3 | Moustafa | Egypt | +--------------+-----------+-------------+ -Product table:
+--------------+-------------+-------------+ | product_id | description | price | @@ -87,7 +86,6 @@ Customers table: | 30 | LC Book | 45 | | 40 | LC Keychain | 2 | +--------------+-------------+-------------+ -Orders table:
+--------------+-------------+-------------+-------------+-----------+ | order_id | customer_id | product_id | order_date | quantity | @@ -101,17 +99,16 @@ Customers table: | 7 | 3 | 30 | 2020-06-25 | 2 | | 9 | 3 | 30 | 2020-05-08 | 3 | +--------------+-------------+-------------+-------------+-----------+ - 输出: +--------------+------------+ | customer_id | name | +--------------+------------+ | 1 | Winston | +--------------+------------+ -解释: -Winston 在2020年6月花费了300(300 * 1), 在7月花费了100(10 * 1 + 45 * 2). -Jonathan 在2020年6月花费了600(300 * 2), 在7月花费了20(2 * 10). -Moustafa 在2020年6月花费了110 (10 * 2 + 45 * 2), 在7月花费了0.
-
Write an SQL query to report the customer_id
and customer_name
of customers who have spent at least 100
in each month of June and July 2020.
Write a solution to report the customer_id
and customer_name
of customers who have spent at least $100
in each month of June and July 2020.
Return the result table in any order.
-The query result format is in the following example.
+The result format is in the following example.
Example 1:
@@ -105,9 +105,9 @@ Orders table: | 1 | Winston | +--------------+------------+ Explanation: -Winston spent 300 (300 * 1) in June and 100 ( 10 * 1 + 45 * 2) in July 2020. -Jonathan spent 600 (300 * 2) in June and 20 ( 2 * 10) in July 2020. -Moustafa spent 110 (10 * 2 + 45 * 2) in June and 0 in July 2020. +Winston spent $300 (300 * 1) in June and $100 ( 10 * 1 + 45 * 2) in July 2020. +Jonathan spent $600 (300 * 2) in June and $20 ( 2 * 10) in July 2020. +Moustafa spent $110 (10 * 2 + 45 * 2) in June and $0 in July 2020. ## Solutions diff --git a/solution/1500-1599/1538.Guess the Majority in a Hidden Array/README.md b/solution/1500-1599/1538.Guess the Majority in a Hidden Array/README.md index 4dd616af1ff0e..30f83b65cdcf9 100644 --- a/solution/1500-1599/1538.Guess the Majority in a Hidden Array/README.md +++ b/solution/1500-1599/1538.Guess the Majority in a Hidden Array/README.md @@ -10,6 +10,7 @@int query(int a, int b, int c, int d)
:其中 0 <= a < b < c < d < ArrayReader.length()
。此函数查询以这四个参数为下标的元素并返回:
+
int length()
:返回数组的长度。你可以调用 query()
最多 2 * n 次,其中 n 等于 ArrayReader.length()
。
int query(int a, int b, int c, int d)
: where 0 <= a < b < c < d < ArrayReader.length()
. The function returns the distribution of the value of the 4 elements and returns:
+
int length()
: Returns the size of the array.You are allowed to call query()
2 * n times at most where n is equal to ArrayReader.length()
.
-
Write an SQL query to find the number of unique orders and the number of unique customers with invoices > $20 for each different month.
+Write a solution to find the number of unique orders and the number of unique customers with invoices > $20 for each different month.
Return the result table sorted in any order.
-The query result format is in the following example.
+The result format is in the following example.
Example 1:
@@ -57,11 +57,11 @@ Orders table: | 2021-01 | 1 | 1 | +---------+-------------+----------------+ Explanation: -In September 2020 we have two orders from 2 different customers with invoices > 20. -In October 2020 we have two orders from 1 customer, and only one of the two orders has invoice > 20. -In November 2020 we have two orders from 2 different customers but invoices < 20, so we don't include that month. -In December 2020 we have two orders from 1 customer both with invoices > 20. -In January 2021 we have two orders from 2 different customers, but only one of them with invoice > 20. +In September 2020 we have two orders from 2 different customers with invoices > $20. +In October 2020 we have two orders from 1 customer, and only one of the two orders has invoice > $20. +In November 2020 we have two orders from 2 different customers but invoices < $20, so we don't include that month. +In December 2020 we have two orders from 1 customer both with invoices > $20. +In January 2021 we have two orders from 2 different customers, but only one of them with invoice > $20. ## Solutions diff --git a/solution/1500-1599/1599.Maximum Profit of Operating a Centennial Wheel/README.md b/solution/1500-1599/1599.Maximum Profit of Operating a Centennial Wheel/README.md index e2a68a58af6a7..9d5e8ec237519 100644 --- a/solution/1500-1599/1599.Maximum Profit of Operating a Centennial Wheel/README.md +++ b/solution/1500-1599/1599.Maximum Profit of Operating a Centennial Wheel/README.md @@ -6,9 +6,9 @@ -你正在经营一座摩天轮,该摩天轮共有 4 个座舱 ,每个座舱 最多可以容纳 4 位游客 。你可以 逆时针 轮转座舱,但每次轮转都需要支付一定的运行成本 runningCost
。摩天轮每次轮转都恰好转动 1 / 4 周。
你正在经营一座摩天轮,该摩天轮共有 4 个座舱 ,每个座舱 最多可以容纳 4 位游客 。你可以 逆时针 轮转座舱,但每次轮转都需要支付一定的运行成本 runningCost
。
给你一个长度为 n
的数组 customers
, customers[i]
是在第 i
次轮转(下标从 0 开始)之前到达的新游客的数量。这也意味着你必须在新游客到来前轮转 i
次。每位游客在登上离地面最近的座舱前都会支付登舱成本 boardingCost
,一旦该座舱再次抵达地面,他们就会离开座舱结束游玩。
给你一个长度为 n
的数组 customers
, customers[i]
是在第 i
次轮转(下标从 0 开始)之前到达的新游客的数量。这也意味着你必须在新游客到来前轮转 i
次。如果有座舱空闲就不能让游客等待。每位游客在登上离地面最近的座舱前都会支付登舱成本 boardingCost
,一旦该座舱再次抵达地面,他们就会离开座舱结束游玩。
你可以随时停下摩天轮,即便是 在服务所有游客之前 。如果你决定停止运营摩天轮,为了保证所有游客安全着陆,将免费进行所有后续轮转 。注意,如果有超过 4 位游客在等摩天轮,那么只有 4 位游客可以登上摩天轮,其余的需要等待 下一次轮转 。
@@ -24,10 +24,10 @@ 输入:customers = [8,3], boardingCost = 5, runningCost = 6 输出:3 解释:座舱上标注的数字是该座舱的当前游客数。 -1. 8 位游客抵达,4 位登舱,4 位等待下一舱,摩天轮轮转。当前利润为 4 * 5 - 1 * 6 = 14 。 -2. 3 位游客抵达,4 位在等待的游客登舱,其他 3 位等待,摩天轮轮转。当前利润为 8 * 5 - 2 * 6 = 28 。 -3. 最后 3 位游客登舱,摩天轮轮转。当前利润为 11 * 5 - 3 * 6 = 37 。 -轮转 3 次得到最大利润,最大利润为 37 。 +1. 8 位游客抵达,4 位登舱,4 位等待下一舱,摩天轮轮转。当前利润为 4 * $5 - 1 * $6 = $14 。 +2. 3 位游客抵达,4 位在等待的游客登舱,其他 3 位等待,摩天轮轮转。当前利润为 8 * $5 - 2 * $6 = $28 。 +3. 最后 3 位游客登舱,摩天轮轮转。当前利润为 11 * $5 - 3 * $6 = $37 。 +轮转 3 次得到最大利润,最大利润为 $37 。示例 2:
@@ -35,14 +35,14 @@ 输入:customers = [10,9,6], boardingCost = 6, runningCost = 4 输出:7 解释: -1. 10 位游客抵达,4 位登舱,6 位等待下一舱,摩天轮轮转。当前利润为 4 * 6 - 1 * 4 = 20 。 -2. 9 位游客抵达,4 位登舱,11 位等待(2 位是先前就在等待的,9 位新加入等待的),摩天轮轮转。当前利润为 8 * 6 - 2 * 4 = 40 。 -3. 最后 6 位游客抵达,4 位登舱,13 位等待,摩天轮轮转。当前利润为 12 * 6 - 3 * 4 = 60 。 -4. 4 位登舱,9 位等待,摩天轮轮转。当前利润为 16 * 6 - 4 * 4 = 80 。 -5. 4 位登舱,5 位等待,摩天轮轮转。当前利润为 20 * 6 - 5 * 4 = 100 。 -6. 4 位登舱,1 位等待,摩天轮轮转。当前利润为 24 * 6 - 6 * 4 = 120 。 -7. 1 位登舱,摩天轮轮转。当前利润为 25 * 6 - 7 * 4 = 122 。 -轮转 7 次得到最大利润,最大利润为 122 。 +1. 10 位游客抵达,4 位登舱,6 位等待下一舱,摩天轮轮转。当前利润为 4 * $6 - 1 * $4 = $20 。 +2. 9 位游客抵达,4 位登舱,11 位等待(2 位是先前就在等待的,9 位新加入等待的),摩天轮轮转。当前利润为 8 * $6 - 2 * $4 = $40 。 +3. 最后 6 位游客抵达,4 位登舱,13 位等待,摩天轮轮转。当前利润为 12 * $6 - 3 * $4 = $60 。 +4. 4 位登舱,9 位等待,摩天轮轮转。当前利润为 * $6 - 4 * $4 = $80 。 +5. 4 位登舱,5 位等待,摩天轮轮转。当前利润为 20 * $6 - 5 * $4 = $100 。 +6. 4 位登舱,1 位等待,摩天轮轮转。当前利润为 24 * $6 - 6 * $4 = $120 。 +7. 1 位登舱,摩天轮轮转。当前利润为 25 * $6 - 7 * $4 = $122 。 +轮转 7 次得到最大利润,最大利润为$122 。示例 3:
@@ -51,11 +51,11 @@ 输入:customers = [3,4,0,5,1], boardingCost = 1, runningCost = 92 输出:-1 解释: -1. 3 位游客抵达,3 位登舱,0 位等待,摩天轮轮转。当前利润为 3 * 1 - 1 * 92 = -89 。 -2. 4 位游客抵达,4 位登舱,0 位等待,摩天轮轮转。当前利润为 7 * 1 - 2 * 92 = -177 。 -3. 0 位游客抵达,0 位登舱,0 位等待,摩天轮轮转。当前利润为 7 * 1 - 3 * 92 = -269 。 -4. 5 位游客抵达,4 位登舱,1 位等待,摩天轮轮转。当前利润为 12 * 1 - 4 * 92 = -356 。 -5. 1 位游客抵达,2 位登舱,0 位等待,摩天轮轮转。当前利润为 13 * 1 - 5 * 92 = -447 。 +1. 3 位游客抵达,3 位登舱,0 位等待,摩天轮轮转。当前利润为 3 * $1 - 1 * $92 = -$89 。 +2. 4 位游客抵达,4 位登舱,0 位等待,摩天轮轮转。当前利润为 7 * $1 - 2 * $92 = -$177 。 +3. 0 位游客抵达,0 位登舱,0 位等待,摩天轮轮转。当前利润为 7 * $1 - 3 * $92 = -$269 。 +4. 5 位游客抵达,4 位登舱,1 位等待,摩天轮轮转。当前利润为 11 * $1 - 4 * $92 = -$357 。 +5. 1 位游客抵达,2 位登舱,0 位等待,摩天轮轮转。当前利润为 13 * $1 - 5 * $92 = -$447 。 利润永不为正,所以返回 -1 。 diff --git a/solution/1500-1599/1599.Maximum Profit of Operating a Centennial Wheel/README_EN.md b/solution/1500-1599/1599.Maximum Profit of Operating a Centennial Wheel/README_EN.md index e05fd99543aa5..8b4f9b3c5ea36 100644 --- a/solution/1500-1599/1599.Maximum Profit of Operating a Centennial Wheel/README_EN.md +++ b/solution/1500-1599/1599.Maximum Profit of Operating a Centennial Wheel/README_EN.md @@ -19,10 +19,10 @@ Input: customers = [8,3], boardingCost = 5, runningCost = 6 Output: 3 Explanation: The numbers written on the gondolas are the number of people currently there. -1. 8 customers arrive, 4 board and 4 wait for the next gondola, the wheel rotates. Current profit is 4 * 5 - 1 * 6 = 14. -2. 3 customers arrive, the 4 waiting board the wheel and the other 3 wait, the wheel rotates. Current profit is 8 * 5 - 2 * 6 = 28. -3. The final 3 customers board the gondola, the wheel rotates. Current profit is 11 * 5 - 3 * 6 = 37. -The highest profit was 37 after rotating the wheel 3 times. +1. 8 customers arrive, 4 board and 4 wait for the next gondola, the wheel rotates. Current profit is 4 * $5 - 1 * $6 = $14. +2. 3 customers arrive, the 4 waiting board the wheel and the other 3 wait, the wheel rotates. Current profit is 8 * $5 - 2 * $6 = $28. +3. The final 3 customers board the gondola, the wheel rotates. Current profit is 11 * $5 - 3 * $6 = $37. +The highest profit was $37 after rotating the wheel 3 times.Example 2:
@@ -31,14 +31,14 @@ The highest profit was 37 after rotating the wheel 3 times. Input: customers = [10,9,6], boardingCost = 6, runningCost = 4 Output: 7 Explanation: -1. 10 customers arrive, 4 board and 6 wait for the next gondola, the wheel rotates. Current profit is 4 * 6 - 1 * 4 = 20. -2. 9 customers arrive, 4 board and 11 wait (2 originally waiting, 9 newly waiting), the wheel rotates. Current profit is 8 * 6 - 2 * 4 = 40. -3. The final 6 customers arrive, 4 board and 13 wait, the wheel rotates. Current profit is 12 * 6 - 3 * 4 = 60. -4. 4 board and 9 wait, the wheel rotates. Current profit is 16 * 6 - 4 * 4 = 80. -5. 4 board and 5 wait, the wheel rotates. Current profit is 20 * 6 - 5 * 4 = 100. -6. 4 board and 1 waits, the wheel rotates. Current profit is 24 * 6 - 6 * 4 = 120. -7. 1 boards, the wheel rotates. Current profit is 25 * 6 - 7 * 4 = 122. -The highest profit was 122 after rotating the wheel 7 times. +1. 10 customers arrive, 4 board and 6 wait for the next gondola, the wheel rotates. Current profit is 4 * $6 - 1 * $4 = $20. +2. 9 customers arrive, 4 board and 11 wait (2 originally waiting, 9 newly waiting), the wheel rotates. Current profit is 8 * $6 - 2 * $4 = $40. +3. The final 6 customers arrive, 4 board and 13 wait, the wheel rotates. Current profit is 12 * $6 - 3 * $4 = $60. +4. 4 board and 9 wait, the wheel rotates. Current profit is 16 * $6 - 4 * $4 = $80. +5. 4 board and 5 wait, the wheel rotates. Current profit is 20 * $6 - 5 * $4 = $100. +6. 4 board and 1 waits, the wheel rotates. Current profit is 24 * $6 - 6 * $4 = $120. +7. 1 boards, the wheel rotates. Current profit is 25 * $6 - 7 * $4 = $122. +The highest profit was $122 after rotating the wheel 7 times.Example 3:
@@ -47,11 +47,11 @@ The highest profit was 122 after rotating the wheel 7 times. Input: customers = [3,4,0,5,1], boardingCost = 1, runningCost = 92 Output: -1 Explanation: -1. 3 customers arrive, 3 board and 0 wait, the wheel rotates. Current profit is 3 * 1 - 1 * 92 = -89. -2. 4 customers arrive, 4 board and 0 wait, the wheel rotates. Current profit is 7 * 1 - 2 * 92 = -177. -3. 0 customers arrive, 0 board and 0 wait, the wheel rotates. Current profit is 7 * 1 - 3 * 92 = -269. -4. 5 customers arrive, 4 board and 1 waits, the wheel rotates. Current profit is 11 * 1 - 4 * 92 = -357. -5. 1 customer arrives, 2 board and 0 wait, the wheel rotates. Current profit is 13 * 1 - 5 * 92 = -447. +1. 3 customers arrive, 3 board and 0 wait, the wheel rotates. Current profit is 3 * $1 - 1 * $92 = -$89. +2. 4 customers arrive, 4 board and 0 wait, the wheel rotates. Current profit is 7 * $1 - 2 * $92 = -$177. +3. 0 customers arrive, 0 board and 0 wait, the wheel rotates. Current profit is 7 * $1 - 3 * $92 = -$269. +4. 5 customers arrive, 4 board and 1 waits, the wheel rotates. Current profit is 11 * $1 - 4 * $92 = -$357. +5. 1 customer arrives, 2 board and 0 wait, the wheel rotates. Current profit is 13 * $1 - 5 * $92 = -$447. The profit was never positive, so return -1. diff --git a/solution/1600-1699/1614.Maximum Nesting Depth of the Parentheses/README.md b/solution/1600-1699/1614.Maximum Nesting Depth of the Parentheses/README.md index 7323cae574d0f..a14024ae18fce 100644 --- a/solution/1600-1699/1614.Maximum Nesting Depth of the Parentheses/README.md +++ b/solution/1600-1699/1614.Maximum Nesting Depth of the Parentheses/README.md @@ -6,7 +6,7 @@ -如果字符串满足以下条件之一,则可以称之为 有效括号字符串(valid parentheses string,可以简写为 VPS):
+如果字符串满足以下条件之一,则可以称之为 有效括号字符串(valid parentheses string,可以简写为 VPS):
""
,或者是一个不为 "("
或 ")"
的单字符。(x1, y1)
字典序比另一个坐标 (x2, y2)
小,需满足以下条件之一:
+
x1 < x2
,x1 == x2
且 y1 < y2
。⌊val⌋
表示小于等于 val
的最大整数(向下取整函数)。diff --git a/solution/1600-1699/1657.Determine if Two Strings Are Close/README.md b/solution/1600-1699/1657.Determine if Two Strings Are Close/README.md index 2b231cf251f69..d40983cf100f6 100644 --- a/solution/1600-1699/1657.Determine if Two Strings Are Close/README.md +++ b/solution/1600-1699/1657.Determine if Two Strings Are Close/README.md @@ -10,6 +10,7 @@
abcde -> aecdb
aacabb -> bbcbaa
(所有 a
转化为 b
,而所有的 b
转换为 a
)你可以根据需要对任意一个字符串多次使用这两种操作。
diff --git a/solution/1600-1699/1657.Determine if Two Strings Are Close/README_EN.md b/solution/1600-1699/1657.Determine if Two Strings Are Close/README_EN.md index 22ee484a983e0..07542498527ee 100644 --- a/solution/1600-1699/1657.Determine if Two Strings Are Close/README_EN.md +++ b/solution/1600-1699/1657.Determine if Two Strings Are Close/README_EN.md @@ -8,6 +8,7 @@abcde -> aecdb
aacabb -> bbcbaa
(all a
's turn into b
's, and all b
's turn into a
's)You can use the operations on either string as many times as necessary.
diff --git a/solution/1600-1699/1675.Minimize Deviation in Array/README.md b/solution/1600-1699/1675.Minimize Deviation in Array/README.md index 5c03da2b12026..ddd047d45811b 100644 --- a/solution/1600-1699/1675.Minimize Deviation in Array/README.md +++ b/solution/1600-1699/1675.Minimize Deviation in Array/README.md @@ -12,6 +12,7 @@2
+
[1,2,3,4]
,那么你可以对最后一个元素执行此操作,使其变成 [1,2,3,2]
[1,2,3,4]
,那么你可以对第一个元素执行此操作,使其变成 [2,2,3,4]
数组的 偏移量 是数组中任意两个元素之间的 最大差值 。
diff --git a/solution/1600-1699/1675.Minimize Deviation in Array/README_EN.md b/solution/1600-1699/1675.Minimize Deviation in Array/README_EN.md index 473558e3830e1..475ec55a94004 100644 --- a/solution/1600-1699/1675.Minimize Deviation in Array/README_EN.md +++ b/solution/1600-1699/1675.Minimize Deviation in Array/README_EN.md @@ -10,6 +10,7 @@2
.
+
[1,2,3,4]
, then you can do this operation on the last element, and the array will be [1,2,3,2].
[1,2,3,4]
, then you can do this operation on the first element, and the array will be [2,2,3,4].
The deviation of the array is the maximum difference between any two elements in the array.
diff --git a/solution/1700-1799/1702.Maximum Binary String After Change/README.md b/solution/1700-1799/1702.Maximum Binary String After Change/README.md index 4045482998ca4..c551721ac3d77 100644 --- a/solution/1700-1799/1702.Maximum Binary String After Change/README.md +++ b/solution/1700-1799/1702.Maximum Binary String After Change/README.md @@ -10,6 +10,7 @@"00"
,你可以用 "10"
将其替换。
+
"00010" -> "10010"
"00010" -> "00001"
请你返回执行上述操作任意次以后能得到的 最大二进制字符串 。如果二进制字符串 x
对应的十进制数字大于二进制字符串 y
对应的十进制数字,那么我们称二进制字符串 x
大于二进制字符串 y
。
"00"
, you can replace it with "10"
.
+
"00010" -> "10010
""00010" -> "00001"
Return the maximum binary string you can obtain after any number of operations. Binary string x
is greater than binary string y
if x
's decimal representation is greater than y
's decimal representation.
"ab"
并得到 x
分。
+
"cabxbae"
删除 ab
,得到 "cxbae"
。"cabxbae"
删除 ba
,得到 "cabxe"
。请返回对 s
字符串执行上面操作若干次能得到的最大得分。
"ab"
and gain x
points.
+
"ab"
from "cabxbae"
it becomes "cxbae"
."ba"
from "cabxbae"
it becomes "cabxe"
.Return the maximum points you can gain after applying the above operations on s
.
word1
非空,将 word1
中的第一个字符附加到 merge
的末尾,并将其从 word1
中移除。
+
word1 = "abc"
且 merge = "dv"
,在执行此选项操作之后,word1 = "bc"
,同时 merge = "dva"
。word2 = "abc"
且 merge = ""
,在执行此选项操作之后,word2 = "bc"
,同时 merge = "a"
。返回你可以构造的字典序 最大 的合并字符串 merge
。
word1
is non-empty, append the first character in word1
to merge
and delete it from word1
.
+
word1 = "abc"
and merge = "dv"
, then after choosing this operation, word1 = "bc"
and merge = "dva"
.word2 = "abc"
and merge = ""
, then after choosing this operation, word2 = "bc"
and merge = "a"
.Return the lexicographically largest merge
you can construct.
5
个球,你可以把它们分到两个新袋子里,分别有 1
个和 4
个球,或者分别有 2
个和 3
个球。你的开销是单个袋子里球数目的 最大值 ,你想要 最小化 开销。
diff --git a/solution/1700-1799/1760.Minimum Limit of Balls in a Bag/README_EN.md b/solution/1700-1799/1760.Minimum Limit of Balls in a Bag/README_EN.md index 18e851029113c..8200c446725ac 100644 --- a/solution/1700-1799/1760.Minimum Limit of Balls in a Bag/README_EN.md +++ b/solution/1700-1799/1760.Minimum Limit of Balls in a Bag/README_EN.md @@ -10,10 +10,12 @@5
balls can become two new bags of 1
and 4
balls, or two new bags of 2
and 3
balls.Your penalty is the maximum number of balls in a bag. You want to minimize your penalty after the operations.
diff --git a/solution/1800-1899/1850.Minimum Adjacent Swaps to Reach the Kth Smallest Number/README.md b/solution/1800-1899/1850.Minimum Adjacent Swaps to Reach the Kth Smallest Number/README.md index 1e76b65b779e6..fd685e96645c8 100644 --- a/solution/1800-1899/1850.Minimum Adjacent Swaps to Reach the Kth Smallest Number/README.md +++ b/solution/1800-1899/1850.Minimum Adjacent Swaps to Reach the Kth Smallest Number/README.md @@ -12,6 +12,7 @@num = "5489355142"
:
+
"5489355214"
"5489355241"
"5489355421"
返回要得到第 k
个 最小妙数 需要对 num
执行的 相邻位数字交换的最小次数 。
num = "5489355142"
:
+
"5489355214"
."5489355241"
."5489355421"
.Return the minimum number of adjacent digit swaps that needs to be applied to num
to reach the kth
smallest wonderful integer.
4
, you can:
+
4
,3
and one ribbon of length 1
,1
.Your goal is to obtain k
ribbons of all the same positive integer length. You are allowed to throw away any excess ribbon as a result of cutting.
i
和 j
(i != j
),并 更新 triplets[j]
为 [max(ai, aj), max(bi, bj), max(ci, cj)]
。
+
triplets[i] = [2, 5, 3]
且 triplets[j] = [1, 7, 5]
,triplets[j]
将会更新为 [max(2, 1), max(5, 7), max(3, 5)] = [2, 7, 5]
。如果通过以上操作我们可以使得目标 三元组 target
成为 triplets
的一个 元素 ,则返回 true
;否则,返回 false
。
i
and j
(i != j
) and update triplets[j]
to become [max(ai, aj), max(bi, bj), max(ci, cj)]
.
+
triplets[i] = [2, 5, 3]
and triplets[j] = [1, 7, 5]
, triplets[j]
will be updated to [max(2, 1), max(5, 7), max(3, 5)] = [2, 7, 5]
.Return true
if it is possible to obtain the target
triplet [x, y, z]
as an element of triplets
, or false
otherwise.
给你一个 从 0 开始的排列 nums
(下标也从 0 开始)。请你构建一个 同样长度 的数组 ans
,其中,对于每个 i
(0 <= i < nums.length
),都满足 ans[i] = nums[nums[i]]
。返回构建好的数组 ans
。
从 0 开始的排列 nums
是一个由 0
到 nums.length - 1
(0
和 nums.length - 1
也包含在内)的不同整数组成的数组。
从 0 开始的排列 nums
是一个由 0
到 nums.length - 1
(0
和 nums.length - 1
也包含在内)的不同整数组成的数组。
+
示例 1:
-输入:nums = [0,2,1,5,3,4] ++输入:nums = [0,2,1,5,3,4] 输出:[0,1,2,4,5,3] 解释:数组 ans 构建如下: ans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]] @@ -23,14 +24,15 @@ ans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]]示例 2:
-输入:nums = [5,0,1,2,3,4] ++输入:nums = [5,0,1,2,3,4] 输出:[4,5,0,1,2,3] 解释:数组 ans 构建如下: ans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]] = [nums[5], nums[0], nums[1], nums[2], nums[3], nums[4]] = [4,5,0,1,2,3]-+
提示:
@@ -40,6 +42,10 @@ ans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]]
nums
中的元素 互不相同+ +
进阶:你能在不使用额外空间的情况下解决此问题吗(即 O(1)
内存)?
Input: maxTime = 30, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3] Output: 11 -Explanation: The path to take is 0 -> 1 -> 2 -> 5, which takes 30 minutes and has 11 worth of passing fees. +Explanation: The path to take is 0 -> 1 -> 2 -> 5, which takes 30 minutes and has $11 worth of passing fees.
Example 2:
@@ -30,7 +30,7 @@Input: maxTime = 29, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3] Output: 48 -Explanation: The path to take is 0 -> 3 -> 4 -> 5, which takes 26 minutes and has 48 worth of passing fees. +Explanation: The path to take is 0 -> 3 -> 4 -> 5, which takes 26 minutes and has $48 worth of passing fees. You cannot take path 0 -> 1 -> 2 -> 5 since it would take too long.diff --git a/solution/1900-1999/1994.The Number of Good Subsets/README.md b/solution/1900-1999/1994.The Number of Good Subsets/README.md index e57a40e2fe36d..aa038633cd294 100644 --- a/solution/1900-1999/1994.The Number of Good Subsets/README.md +++ b/solution/1900-1999/1994.The Number of Good Subsets/README.md @@ -10,11 +10,13 @@
nums = [1, 2, 3, 4]
:
+
[2, 3]
,[1, 2, 3]
和 [1, 3]
是 好 子集,乘积分别为 6 = 2*3
,6 = 2*3
和 3 = 3
。[1, 4]
和 [4]
不是 好 子集,因为乘积分别为 4 = 2*2
和 4 = 2*2
。请你返回 nums
中不同的 好 子集的数目对 109 + 7
取余 的结果。
nums = [1, 2, 3, 4]
:
+
[2, 3]
, [1, 2, 3]
, and [1, 3]
are good subsets with products 6 = 2*3
, 6 = 2*3
, and 3 = 3
respectively.[1, 4]
and [4]
are not good subsets with products 4 = 2*2
and 4 = 2*2
respectively.Return the number of different good subsets in nums
modulo 109 + 7
.
-
A company wants to hire new employees. The budget of the company for the salaries is 70000
. The company's criteria for hiring are:
A company wants to hire new employees. The budget of the company for the salaries is $70000
. The company's criteria for hiring are:
Write an SQL query to find the number of seniors and juniors hired under the mentioned criteria.
+Write a solution to find the number of seniors and juniors hired under the mentioned criteria.
Return the result table in any order.
-The query result format is in the following example.
+The result format is in the following example.
Example 1:
@@ -58,8 +58,8 @@ Candidates table: | Junior | 2 | +------------+---------------------+ Explanation: -We can hire 2 seniors with IDs (2, 11). Since the budget is 70000 and the sum of their salaries is 40000, we still have 30000 but they are not enough to hire the senior candidate with ID 13. -We can hire 2 juniors with IDs (1, 9). Since the remaining budget is 30000 and the sum of their salaries is 20000, we still have 10000 but they are not enough to hire the junior candidate with ID 4. +We can hire 2 seniors with IDs (2, 11). Since the budget is $70000 and the sum of their salaries is $40000, we still have $30000 but they are not enough to hire the senior candidate with ID 13. +We can hire 2 juniors with IDs (1, 9). Since the remaining budget is $30000 and the sum of their salaries is $20000, we still have $10000 but they are not enough to hire the junior candidate with ID 4.Example 2:
@@ -85,7 +85,7 @@ Candidates table: | Junior | 3 | +------------+---------------------+ Explanation: -We cannot hire any seniors with the current budget as we need at least 80000 to hire one senior. +We cannot hire any seniors with the current budget as we need at least $80000 to hire one senior. We can hire all three juniors with the remaining budget. diff --git a/solution/2000-2099/2010.The Number of Seniors and Juniors to Join the Company II/README.md b/solution/2000-2099/2010.The Number of Seniors and Juniors to Join the Company II/README.md index 3fa27e830a398..d46293bb4b8bc 100644 --- a/solution/2000-2099/2010.The Number of Seniors and Juniors to Join the Company II/README.md +++ b/solution/2000-2099/2010.The Number of Seniors and Juniors to Join the Company II/README.md @@ -23,7 +23,7 @@ employee_id 是该表中具有唯一值的列。-
一家公司想雇佣新员工。公司的工资预算是 70000
。公司的招聘标准是:
一家公司想雇佣新员工。公司的工资预算是 $70000
。公司的招聘标准是:
-
A company wants to hire new employees. The budget of the company for the salaries is 70000
. The company's criteria for hiring are:
A company wants to hire new employees. The budget of the company for the salaries is $70000
. The company's criteria for hiring are:
buildings = [[1,5,2],[3,10,4]]
, street = [[1,3,2],[3,5,3],[5,10,4]]
可以表示街道,因为:
+
2 / 1 = 2
。(2+4) / 2 = 3
。4 / 1 = 4
。给定 buildings
,返回如上所述的二维整数矩阵 street
( 不包括 街道上没有建筑物的任何区域)。您可以按 任何顺序 返回数组。
diff --git a/solution/2000-2099/2015.Average Height of Buildings in Each Segment/README_EN.md b/solution/2000-2099/2015.Average Height of Buildings in Each Segment/README_EN.md
index 98f2494642974..077abda823b06 100644
--- a/solution/2000-2099/2015.Average Height of Buildings in Each Segment/README_EN.md
+++ b/solution/2000-2099/2015.Average Height of Buildings in Each Segment/README_EN.md
@@ -10,12 +10,14 @@
buildings = [[1,5,2],[3,10,4]],
the street could be represented by street = [[1,3,2],[3,5,3],[5,10,4]]
because:
+
2 / 1 = 2
.(2+4) / 2 = 3
.4 / 1 = 4
.Given buildings
, return the 2D integer array street
as described above (excluding any areas of the street where there are no buldings). You may return the array in any order.
arr = [4, 1, 5, 2, 6, 2]
对于 k = 2
是 K 递增的,因为:
+
arr[0] <= arr[2] (4 <= 5)
arr[1] <= arr[3] (1 <= 2)
arr
对于 k = 1
不是 K 递增的(因为 arr[0] > arr[1]
),对于 k = 3
也不是 K 递增的(因为 arr[0] > arr[3]
)。每一次 操作 中,你可以选择一个下标 i
并将 arr[i]
改成任意 正整数。
arr = [4, 1, 5, 2, 6, 2]
is K-increasing for k = 2
because:
+
arr[0] <= arr[2] (4 <= 5)
arr[1] <= arr[3] (1 <= 2)
arr
is not K-increasing for k = 1
(because arr[0] > arr[1]
) or k = 3
(because arr[0] > arr[3]
).In one operation, you can choose an index i
and change arr[i]
into any positive integer.
C
。
+
1000
中有 3
个后缀 0 ,546
中没有后缀 0 。12345678987600000
被表示为 "12345...89876e5"
。请你返回一个字符串,表示 闭区间 [left, right]
中所有整数 乘积 的 缩写 。
C
.
+
3
trailing zeros in 1000
, and there are 0
trailing zeros in 546
.12345678987600000
will be represented as "12345...89876e5"
.Return a string denoting the abbreviated product of all integers in the inclusive range [left, right]
.
questions = [[3, 2], [4, 3], [4, 4], [2, 5]]
:
+
0
被解决了, 那么你可以获得 3
分,但你不能解决问题 1
和 2
。0
,且解决问题 1
,你将获得 4
分但是不能解决问题 2
和 3
。questions = [[3, 2], [4, 3], [4, 4], [2, 5]]
:
+
0
is solved, you will earn 3
points but you will be unable to solve questions 1
and 2
.0
is skipped and question 1
is solved, you will earn 4
points but you will be unable to solve questions 2
and 3
.differences = [1, -3, 4]
,lower = 1
,upper = 6
,那么隐藏数组是一个长度为 4
且所有值都在 1
和 6
(包含两者)之间的数组。
+
[3, 4, 1, 5]
和 [4, 5, 2, 6]
都是符合要求的隐藏数组。[5, 6, 3, 7]
不符合要求,因为它包含大于 6
的元素。[1, 2, 3, 4]
不符合要求,因为相邻元素的差值不符合给定数据。请你返回 符合 要求的隐藏数组的数目。如果没有符合要求的隐藏数组,请返回 0
。
differences = [1, -3, 4]
, lower = 1
, upper = 6
, the hidden sequence is a sequence of length 4
whose elements are in between 1
and 6
(inclusive).
+
[3, 4, 1, 5]
and [4, 5, 2, 6]
are possible hidden sequences.[5, 6, 3, 7]
is not possible since it contains an element greater than 6
.[1, 2, 3, 4]
is not possible since the differences are not correct.Return the number of possible hidden sequences there are. If there are no possible sequences, return 0
.
nums
奇数下标 上的所有值。
+
nums = [4,1,2,3]
,对奇数下标的值排序后变为 [4,3,2,1]
。奇数下标 1
和 3
的值按照非递增顺序重排。nums = [4,1,2,3]
,对偶数下标的值排序后变为 [2,1,4,3]
。偶数下标 0
和 2
的值按照非递减顺序重排。返回重排 nums
的值之后形成的数组。
nums
in non-increasing order.
+
nums = [4,1,2,3]
before this step, it becomes [4,3,2,1]
after. The values at odd indices 1
and 3
are sorted in non-increasing order.nums = [4,1,2,3]
before this step, it becomes [2,1,4,3]
after. The values at even indices 0
and 2
are sorted in non-decreasing order.Return the array formed after rearranging the values of nums
.
示例 1:
-输入:mapping = [8,9,4,0,2,1,3,5,7,6], nums = [991,338,38] ++输入:mapping = [8,9,4,0,2,1,3,5,7,6], nums = [991,338,38] 输出:[338,38,991] 解释: 将数字 991 按照如下规则映射: 1. mapping[9] = 6 ,所有数位 9 都会变成 6 。 -2. mapping[1] = 9 ,所有数位 1 都会变成 8 。 +2. mapping[1] = 9 ,所有数位 1 都会变成 9 。 所以,991 映射的值为 669 。 338 映射为 007 ,去掉前导 0 后得到 7 。 38 映射为 07 ,去掉前导 0 后得到 7 。 @@ -38,7 +39,8 @@示例 2:
-输入:mapping = [0,1,2,3,4,5,6,7,8,9], nums = [789,456,123] ++输入:mapping = [0,1,2,3,4,5,6,7,8,9], nums = [789,456,123] 输出:[123,456,789] 解释:789 映射为 789 ,456 映射为 456 ,123 映射为 123 。所以排序后数组为 [123,456,789] 。diff --git a/solution/2200-2299/2241.Design an ATM Machine/README.md b/solution/2200-2299/2241.Design an ATM Machine/README.md index 2d81b292a497a..372435a5c9d05 100644 --- a/solution/2200-2299/2241.Design an ATM Machine/README.md +++ b/solution/2200-2299/2241.Design an ATM Machine/README.md @@ -11,16 +11,16 @@取款时,机器会优先取 较大 数额的钱。
300
,并且机器里有 2
张 50
的钞票,1
张 100
的钞票和1
张 200
的钞票,那么机器会取出 100
和 200
的钞票。600
,机器里有 3
张 200
的钞票和1
张 500
的钞票,那么取款请求会被拒绝,因为机器会先取出 500
的钞票,然后无法取出剩余的 100
。注意,因为有 500
钞票的存在,机器 不能 取 200
的钞票。$300
,并且机器里有 2
张 $50
的钞票,1
张 $100
的钞票和1
张 $200
的钞票,那么机器会取出 $100
和 $200
的钞票。$600
,机器里有 3
张 $200
的钞票和1
张 $500
的钞票,那么取款请求会被拒绝,因为机器会先取出 $500
的钞票,然后无法取出剩余的 $100
。注意,因为有 $500
钞票的存在,机器 不能 取 $200
的钞票。请你实现 ATM 类:
ATM()
初始化 ATM 对象。void deposit(int[] banknotesCount)
分别存入 20
,50
,100
,200
和 500
钞票的数目。int[] withdraw(int amount)
返回一个长度为 5
的数组,分别表示 20
,50
,100
,200
和 500
钞票的数目,并且更新 ATM 机里取款后钞票的剩余数量。如果无法取出指定数额的钱,请返回 [-1]
(这种情况下 不 取出任何钞票)。void deposit(int[] banknotesCount)
分别存入 $20
,$50
,$100
,$200
和 $500
钞票的数目。int[] withdraw(int amount)
返回一个长度为 5
的数组,分别表示 $20
,$50
,$100
,$200
和 $500
钞票的数目,并且更新 ATM 机里取款后钞票的剩余数量。如果无法取出指定数额的钱,请返回 [-1]
(这种情况下 不 取出任何钞票)。@@ -36,13 +36,13 @@ 解释: ATM atm = new ATM(); -atm.deposit([0,0,1,2,1]); // 存入 1 张 100 ,2 张 200 和 1 张 500 的钞票。 -atm.withdraw(600); // 返回 [0,0,1,0,1] 。机器返回 1 张 100 和 1 张 500 的钞票。机器里剩余钞票的数量为 [0,0,0,2,0] 。 -atm.deposit([0,1,0,1,1]); // 存入 1 张 50 ,1 张 200 和 1 张 500 的钞票。 +atm.deposit([0,0,1,2,1]); // 存入 1 张 $100 ,2 张 $200 和 1 张 $500 的钞票。 +atm.withdraw(600); // 返回 [0,0,1,0,1] 。机器返回 1 张 $100 和 1 张 $500 的钞票。机器里剩余钞票的数量为 [0,0,0,2,0] 。 +atm.deposit([0,1,0,1,1]); // 存入 1 张 $50 ,1 张 $200 和 1 张 $500 的钞票。 // 机器中剩余钞票数量为 [0,1,0,3,1] 。 -atm.withdraw(600); // 返回 [-1] 。机器会尝试取出 500 的钞票,然后无法得到剩余的 100 ,所以取款请求会被拒绝。 +atm.withdraw(600); // 返回 [-1] 。机器会尝试取出 $500 的钞票,然后无法得到剩余的 $100 ,所以取款请求会被拒绝。 // 由于请求被拒绝,机器中钞票的数量不会发生改变。 -atm.withdraw(550); // 返回 [0,1,0,0,1] ,机器会返回 1 张 50 的钞票和 1 张 500 的钞票。 +atm.withdraw(550); // 返回 [0,1,0,0,1] ,机器会返回 1 张 $50 的钞票和 1 张 $500 的钞票。
diff --git a/solution/2200-2299/2241.Design an ATM Machine/README_EN.md b/solution/2200-2299/2241.Design an ATM Machine/README_EN.md index 1cda656acb3e2..ebcd74de5312e 100644 --- a/solution/2200-2299/2241.Design an ATM Machine/README_EN.md +++ b/solution/2200-2299/2241.Design an ATM Machine/README_EN.md @@ -9,16 +9,16 @@
When withdrawing, the machine prioritizes using banknotes of larger values.
300
and there are 2
50
banknotes, 1
100
banknote, and 1
200
banknote, then the machine will use the 100
and 200
banknotes.600
and there are 3
200
banknotes and 1
500
banknote, then the withdraw request will be rejected because the machine will first try to use the 500
banknote and then be unable to use banknotes to complete the remaining 100
. Note that the machine is not allowed to use the 200
banknotes instead of the 500
banknote.$300
and there are 2
$50
banknotes, 1
$100
banknote, and 1
$200
banknote, then the machine will use the $100
and $200
banknotes.$600
and there are 3
$200
banknotes and 1
$500
banknote, then the withdraw request will be rejected because the machine will first try to use the $500
banknote and then be unable to use banknotes to complete the remaining $100
. Note that the machine is not allowed to use the $200
banknotes instead of the $500
banknote.Implement the ATM class:
ATM()
Initializes the ATM object.void deposit(int[] banknotesCount)
Deposits new banknotes in the order 20
, 50
, 100
, 200
, and 500
.int[] withdraw(int amount)
Returns an array of length 5
of the number of banknotes that will be handed to the user in the order 20
, 50
, 100
, 200
, and 500
, and update the number of banknotes in the ATM after withdrawing. Returns [-1]
if it is not possible (do not withdraw any banknotes in this case).void deposit(int[] banknotesCount)
Deposits new banknotes in the order $20
, $50
, $100
, $200
, and $500
.int[] withdraw(int amount)
Returns an array of length 5
of the number of banknotes that will be handed to the user in the order $20
, $50
, $100
, $200
, and $500
, and update the number of banknotes in the ATM after withdrawing. Returns [-1]
if it is not possible (do not withdraw any banknotes in this case).@@ -33,20 +33,20 @@ Explanation ATM atm = new ATM(); -atm.deposit([0,0,1,2,1]); // Deposits 1 100 banknote, 2 200 banknotes, - // and 1 500 banknote. -atm.withdraw(600); // Returns [0,0,1,0,1]. The machine uses 1 100 banknote - // and 1 500 banknote. The banknotes left over in the +atm.deposit([0,0,1,2,1]); // Deposits 1 $100 banknote, 2 $200 banknotes, + // and 1 $500 banknote. +atm.withdraw(600); // Returns [0,0,1,0,1]. The machine uses 1 $100 banknote + // and 1 $500 banknote. The banknotes left over in the // machine are [0,0,0,2,0]. -atm.deposit([0,1,0,1,1]); // Deposits 1 50, 200, and 500 banknote. +atm.deposit([0,1,0,1,1]); // Deposits 1 $50, $200, and $500 banknote. // The banknotes in the machine are now [0,1,0,3,1]. -atm.withdraw(600); // Returns [-1]. The machine will try to use a 500 banknote - // and then be unable to complete the remaining 100, +atm.withdraw(600); // Returns [-1]. The machine will try to use a $500 banknote + // and then be unable to complete the remaining $100, // so the withdraw request will be rejected. // Since the request is rejected, the number of banknotes // in the machine is not modified. -atm.withdraw(550); // Returns [0,1,0,0,1]. The machine uses 1 50 banknote - // and 1 500 banknote. +atm.withdraw(550); // Returns [0,1,0,0,1]. The machine uses 1 $50 banknote + // and 1 $500 banknote.
Constraints:
@@ -57,6 +57,7 @@ atm.withdraw(550); // Returns [0,1,0,0,1]. The machine uses 1 50 banknote1 <= amount <= 109
5000
calls in total will be made to withdraw
and deposit
.withdraw
and deposit
.banknotesCount[i]
in all deposits doesn't exceed 109
句子 是由若干个单词组成的字符串,单词之间用单个空格分隔,其中每个单词可以包含数字、小写字母、和美元符号 ''
。如果单词的形式为美元符号后跟着一个非负实数,那么这个单词就表示一个 价格 。
句子 是由若干个单词组成的字符串,单词之间用单个空格分隔,其中每个单词可以包含数字、小写字母、和美元符号 '$'
。如果单词的形式为美元符号后跟着一个非负实数,那么这个单词就表示一个 价格 。
"100"
、"23"
和 "6"
表示价格,而 "100"
、""
和 "1e5
不是。"$100"
、"$23"
和 "$6"
表示价格,而 "100"
、"$"
和 "$1e5
不是。给你一个字符串 sentence
表示一个句子和一个整数 discount
。对于每个表示价格的单词,都在价格的基础上减免 discount%
,并 更新 该单词到句子中。所有更新后的价格应该表示为一个 恰好保留小数点后两位 的数字。
示例 1:
-输入:sentence = "there are 1 2 and 5 candies in the shop", discount = 50 -输出:"there are 0.50 1.00 and 5 candies in the shop" +输入:sentence = "there are $1 $2 and 5$ candies in the shop", discount = 50 +输出:"there are $0.50 $1.00 and 5$ candies in the shop" 解释: -表示价格的单词是 "1" 和 "2" 。 -- "1" 减免 50% 为 "0.50" ,所以 "1" 替换为 "0.50" 。 -- "2" 减免 50% 为 "1" ,所以 "1" 替换为 "1.00" 。+表示价格的单词是 "$1" 和 "$2" 。 +- "$1" 减免 50% 为 "$0.50" ,所以 "$1" 替换为 "$0.50" 。 +- "$2" 减免 50% 为 "$1" ,所以 "$1" 替换为 "$1.00" 。
示例 2:
-输入:sentence = "1 2 3 4 5 6 7 8 9 10", discount = 100 -输出:"1 2 0.00 4 0.00 0.00 7 8 0.00 10" +输入:sentence = "1 2 $3 4 $5 $6 7 8$ $9 $10$", discount = 100 +输出:"1 2 $0.00 4 $0.00 $0.00 7 8$ $0.00 $10$" 解释: 任何价格减免 100% 都会得到 0 。 -表示价格的单词分别是 "3"、"5"、"6" 和 "9"。 -每个单词都替换为 "0.00"。 +表示价格的单词分别是 "$3"、"$5"、"$6" 和 "$9"。 +每个单词都替换为 "$0.00"。
@@ -47,7 +47,7 @@
1 <= sentence.length <= 105
sentence
由小写英文字母、数字、' '
和 ''
组成sentence
由小写英文字母、数字、' '
和 '$'
组成sentence
不含前导和尾随空格sentence
的所有单词都用单个空格分隔A sentence is a string of single-space separated words where each word can contain digits, lowercase letters, and the dollar sign ''
. A word represents a price if it is a sequence of digits preceded by a dollar sign.
A sentence is a string of single-space separated words where each word can contain digits, lowercase letters, and the dollar sign '$'
. A word represents a price if it is a sequence of digits preceded by a dollar sign.
"100"
, "23"
, and "6"
represent prices while "100"
, ""
, and "1e5"
do not."$100"
, "$23"
, and "$6"
represent prices while "100"
, "$"
, and "$1e5"
do not.You are given a string sentence
representing a sentence and an integer discount
. For each word representing a price, apply a discount of discount%
on the price and update the word in the sentence. All updated prices should be represented with exactly two decimal places.
Example 1:
-Input: sentence = "there are 1 2 and 5 candies in the shop", discount = 50 -Output: "there are 0.50 1.00 and 5 candies in the shop" +Input: sentence = "there are $1 $2 and 5$ candies in the shop", discount = 50 +Output: "there are $0.50 $1.00 and 5$ candies in the shop" Explanation: -The words which represent prices are "1" and "2". -- A 50% discount on "1" yields "0.50", so "1" is replaced by "0.50". -- A 50% discount on "2" yields "1". Since we need to have exactly 2 decimal places after a price, we replace "2" with "1.00". +The words which represent prices are "$1" and "$2". +- A 50% discount on "$1" yields "$0.50", so "$1" is replaced by "$0.50". +- A 50% discount on "$2" yields "$1". Since we need to have exactly 2 decimal places after a price, we replace "$2" with "$1.00".
Example 2:
-Input: sentence = "1 2 3 4 5 6 7 8 9 10", discount = 100 -Output: "1 2 0.00 4 0.00 0.00 7 8 0.00 10" +Input: sentence = "1 2 $3 4 $5 $6 7 8$ $9 $10$", discount = 100 +Output: "1 2 $0.00 4 $0.00 $0.00 7 8$ $0.00 $10$" Explanation: Applying a 100% discount on any price will result in 0. -The words representing prices are "3", "5", "6", and "9". -Each of them is replaced by "0.00". +The words representing prices are "$3", "$5", "$6", and "$9". +Each of them is replaced by "$0.00".
@@ -44,7 +44,7 @@ Each of them is replaced by "0.00".
1 <= sentence.length <= 105
sentence
consists of lowercase English letters, digits, ' '
, and ''
.sentence
consists of lowercase English letters, digits, ' '
, and '$'
.sentence
does not have leading or trailing spaces.sentence
are separated by a single space.输入:brackets = [[3,50],[7,10],[12,25]], income = 10 输出:2.65000 解释: -前 3 的税率为 50% 。需要支付税款 3 * 50% = 1.50 。 -接下来 7 - 3 = 4 的税率为 10% 。需要支付税款 4 * 10% = 0.40 。 -最后 10 - 7 = 3 的税率为 25% 。需要支付税款 3 * 25% = 0.75 。 -需要支付的税款总计 1.50 + 0.40 + 0.75 = 2.65 。 +前 $3 的税率为 50% 。需要支付税款 $3 * 50% = $1.50 。 +接下来 $7 - $3 = $4 的税率为 10% 。需要支付税款 $4 * 10% = $0.40 。 +最后 $10 - $7 = $3 的税率为 25% 。需要支付税款 $3 * 25% = $0.75 。 +需要支付的税款总计 $1.50 + $0.40 + $0.75 = $2.65 。
示例 2:
@@ -37,9 +37,9 @@输入:brackets = [[1,0],[4,25],[5,50]], income = 2 输出:0.25000 解释: -前 1 的税率为 0% 。需要支付税款 1 * 0% = 0 。 -剩下 1 的税率为 25% 。需要支付税款 1 * 25% = 0.25 。 -需要支付的税款总计 0 + 0.25 = 0.25 。 +前 $1 的税率为 0% 。需要支付税款 $1 * 0% = $0 。 +剩下 $1 的税率为 25% 。需要支付税款 $1 * 25% = $0.25 。 +需要支付的税款总计 $0 + $0.25 = $0.25 。
示例 3:
@@ -47,7 +47,7 @@输入:brackets = [[2,50]], income = 0 输出:0.00000 解释: -没有收入,无需纳税,需要支付的税款总计 0 。 +没有收入,无需纳税,需要支付的税款总计 $0 。
diff --git a/solution/2300-2399/2303.Calculate Amount Paid in Taxes/README_EN.md b/solution/2300-2399/2303.Calculate Amount Paid in Taxes/README_EN.md index cbd6ad7e8f294..a149c7cb97e5c 100644 --- a/solution/2300-2399/2303.Calculate Amount Paid in Taxes/README_EN.md +++ b/solution/2300-2399/2303.Calculate Amount Paid in Taxes/README_EN.md @@ -26,7 +26,7 @@ Explanation: Based on your income, you have 3 dollars in the 1st tax bracket, 4 dollars in the 2nd tax bracket, and 3 dollars in the 3rd tax bracket. The tax rate for the three tax brackets is 50%, 10%, and 25%, respectively. -In total, you pay 3 * 50% + 4 * 10% + 3 * 25% = 2.65 in taxes. +In total, you pay $3 * 50% + $4 * 10% + $3 * 25% = $2.65 in taxes.
Example 2:
@@ -37,7 +37,7 @@ In total, you pay 3 * 50% + 4 * 10% + 3 * 25% = 2.65 in taxes. Explanation: Based on your income, you have 1 dollar in the 1st tax bracket and 1 dollar in the 2nd tax bracket. The tax rate for the two tax brackets is 0% and 25%, respectively. -In total, you pay 1 * 0% + 1 * 25% = 0.25 in taxes. +In total, you pay $1 * 0% + $1 * 25% = $0.25 in taxes.Example 3:
@@ -46,7 +46,7 @@ In total, you pay 1 * 0% + 1 * 25% = 0.25 in taxes. Input: brackets = [[2,50]], income = 0 Output: 0.00000 Explanation: -You have no income to tax, so you have to pay a total of 0 in taxes. +You have no income to tax, so you have to pay a total of $0 in taxes.diff --git a/solution/2300-2399/2353.Design a Food Rating System/README.md b/solution/2300-2399/2353.Design a Food Rating System/README.md index 6071a92fc0010..a1816e2181489 100644 --- a/solution/2300-2399/2353.Design a Food Rating System/README.md +++ b/solution/2300-2399/2353.Design a Food Rating System/README.md @@ -17,6 +17,7 @@
FoodRatings(String[] foods, String[] cuisines, int[] ratings)
初始化系统。食物由 foods
、cuisines
和 ratings
描述,长度均为 n
。
+
foods[i]
是第 i
种食物的名字。cuisines[i]
是第 i
种食物的烹饪方式。void changeRating(String food, int newRating)
修改名字为 food
的食物的评分。String highestRated(String cuisine)
返回指定烹饪方式 cuisine
下评分最高的食物的名字。如果存在并列,返回 字典序较小 的名字。注意,字符串 x
的字典序比字符串 y
更小的前提是:x
在字典中出现的位置在 y
之前,也就是说,要么 x
是 y
的前缀,或者在满足 x[i] != y[i]
的第一个位置 i
处,x[i]
在字母表中出现的位置在 y[i]
之前。
FoodRatings(String[] foods, String[] cuisines, int[] ratings)
Initializes the system. The food items are described by foods
, cuisines
and ratings
, all of which have a length of n
.
+
foods[i]
is the name of the ith
food,cuisines[i]
is the type of cuisine of the ith
food, andvoid changeRating(String food, int newRating)
Changes the rating of the food item with the name food
.String highestRated(String cuisine)
Returns the name of the food item that has the highest rating for the given type of cuisine
. If there is a tie, return the item with the lexicographically smaller name.Note that a string x
is lexicographically smaller than string y
if x
comes before y
in dictionary order, that is, either x
is a prefix of y
, or if i
is the first position such that x[i] != y[i]
, then x[i]
comes before y[i]
in alphabetic order.
-
编写一个 SQL 查询来显示价格最高的发票的详细信息。如果两个或多个发票具有相同的价格,则返回 invoice_id
最小的发票的详细信息。
编写解决方案,展示价格最高的发票的详细信息。如果两个或多个发票具有相同的价格,则返回 invoice_id
最小的发票的详细信息。
以 任意顺序 返回结果表。
-查询结果格式示例如下。
+结果格式示例如下。
@@ -74,10 +74,10 @@ Purchases 表: | 1 | 4 | 400 | +------------+----------+-------+ 解释: -发票 1: price = (2 * 100) = 200 -发票 2: price = (4 * 100) + (3 * 200) = 1000 -发票 3: price = (1 * 200) = 200 -发票 4: price = (10 * 100) = 1000 +发票 1: price = (2 * 100) = $200 +发票 2: price = (4 * 100) + (3 * 200) = $1000 +发票 3: price = (1 * 200) = $200 +发票 4: price = (10 * 100) = $1000 最高价格是 1000 美元,最高价格的发票是 2 和 4。我们返回 ID 最小的发票 2 的详细信息。 diff --git a/solution/2300-2399/2362.Generate the Invoice/README_EN.md b/solution/2300-2399/2362.Generate the Invoice/README_EN.md index e75a073e7d11a..e1613a0c9a52e 100644 --- a/solution/2300-2399/2362.Generate the Invoice/README_EN.md +++ b/solution/2300-2399/2362.Generate the Invoice/README_EN.md @@ -13,7 +13,7 @@ | product_id | int | | price | int | +-------------+------+ -product_id is the primary key for this table. +product_id contains unique values. Each row in this table shows the ID of a product and the price of one unit. @@ -29,17 +29,17 @@ Each row in this table shows the ID of a product and the price of one unit. | product_id | int | | quantity | int | +-------------+------+ -(invoice_id, product_id) is the primary key for this table. +(invoice_id, product_id) is the primary key (combination of columns with unique values) for this table. Each row in this table shows the quantity ordered from one product in an invoice.
-
Write an SQL query to show the details of the invoice with the highest price. If two or more invoices have the same price, return the details of the one with the smallest invoice_id
.
Write a solution to show the details of the invoice with the highest price. If two or more invoices have the same price, return the details of the one with the smallest invoice_id
.
Return the result table in any order.
-The query result format is shown in the following example.
+The result format is shown in the following example.
Example 1:
@@ -71,12 +71,12 @@ Purchases table: | 1 | 4 | 400 | +------------+----------+-------+ Explanation: -Invoice 1: price = (2 * 100) = 200 -Invoice 2: price = (4 * 100) + (3 * 200) = 1000 -Invoice 3: price = (1 * 200) = 200 -Invoice 4: price = (10 * 100) = 1000 +Invoice 1: price = (2 * 100) = $200 +Invoice 2: price = (4 * 100) + (3 * 200) = $1000 +Invoice 3: price = (1 * 200) = $200 +Invoice 4: price = (10 * 100) = $1000 -The highest price is 1000, and the invoices with the highest prices are 2 and 4. We return the details of the one with the smallest ID, which is invoice 2. +The highest price is $1000, and the invoices with the highest prices are 2 and 4. We return the details of the one with the smallest ID, which is invoice 2. ## Solutions diff --git a/solution/2400-2499/2422.Merge Operations to Turn Array Into a Palindrome/README.md b/solution/2400-2499/2422.Merge Operations to Turn Array Into a Palindrome/README.md index 283347ee7f457..9f85f4d9764de 100644 --- a/solution/2400-2499/2422.Merge Operations to Turn Array Into a Palindrome/README.md +++ b/solution/2400-2499/2422.Merge Operations to Turn Array Into a Palindrome/README.md @@ -12,10 +12,12 @@nums = [1,2,3,1]
,则可以应用一个操作使其变为 [1,5,1]
。返回将数组转换为 回文序列 所需的 最小 操作数。
diff --git a/solution/2400-2499/2422.Merge Operations to Turn Array Into a Palindrome/README_EN.md b/solution/2400-2499/2422.Merge Operations to Turn Array Into a Palindrome/README_EN.md index e98de481f0294..250bf4376d531 100644 --- a/solution/2400-2499/2422.Merge Operations to Turn Array Into a Palindrome/README_EN.md +++ b/solution/2400-2499/2422.Merge Operations to Turn Array Into a Palindrome/README_EN.md @@ -10,10 +10,12 @@nums = [1,2,3,1]
, you can apply one operation to make it [1,5,1]
.Return the minimum number of operations needed to turn the array into a palindrome.
diff --git a/solution/2400-2499/2488.Count Subarrays With Median K/README.md b/solution/2400-2499/2488.Count Subarrays With Median K/README.md index e77be1d758ca2..78e78e9d200b9 100644 --- a/solution/2400-2499/2488.Count Subarrays With Median K/README.md +++ b/solution/2400-2499/2488.Count Subarrays With Median K/README.md @@ -14,11 +14,13 @@[2,3,1,4]
的中位数是 2
,[8,4,3,5,1]
的中位数是 4
。diff --git a/solution/2400-2499/2488.Count Subarrays With Median K/README_EN.md b/solution/2400-2499/2488.Count Subarrays With Median K/README_EN.md index 7d18e2e92c7cc..0f9062f74a035 100644 --- a/solution/2400-2499/2488.Count Subarrays With Median K/README_EN.md +++ b/solution/2400-2499/2488.Count Subarrays With Median K/README_EN.md @@ -12,11 +12,13 @@
[2,3,1,4]
is 2
, and the median of [8,4,3,5,1]
is 4
.diff --git a/solution/2500-2599/2525.Categorize Box According to Criteria/README.md b/solution/2500-2599/2525.Categorize Box According to Criteria/README.md index 531e8a820c343..db0597d66ed63 100644 --- a/solution/2500-2599/2525.Categorize Box According to Criteria/README.md +++ b/solution/2500-2599/2525.Categorize Box According to Criteria/README.md @@ -10,6 +10,7 @@
"Bulky"
的:
+
104
。109
。"Bulky"
,也不是 "Heavy"
,那么返回类别为 "Neither"
。"Bulky"
但不是 "Heavy"
,那么返回类别为 "Bulky"
。"Heavy"
但不是 "Bulky"
,那么返回类别为 "Heavy"
。注意,箱子的体积等于箱子的长度、宽度和高度的乘积。
diff --git a/solution/2500-2599/2525.Categorize Box According to Criteria/README_EN.md b/solution/2500-2599/2525.Categorize Box According to Criteria/README_EN.md index 55af69ca88525..425662af4cf2c 100644 --- a/solution/2500-2599/2525.Categorize Box According to Criteria/README_EN.md +++ b/solution/2500-2599/2525.Categorize Box According to Criteria/README_EN.md @@ -8,6 +8,7 @@"Bulky"
if:
+
104
.109
."Bulky"
nor "Heavy"
, then its category is "Neither"
."Bulky"
but not "Heavy"
, then its category is "Bulky"
."Heavy"
but not "Bulky"
, then its category is "Heavy"
.Note that the volume of the box is the product of its length, width and height.
diff --git a/solution/2500-2599/2578.Split With Minimum Sum/README.md b/solution/2500-2599/2578.Split With Minimum Sum/README.md index ff9b8e68a911e..02706b19feeca 100644 --- a/solution/2500-2599/2578.Split With Minimum Sum/README.md +++ b/solution/2500-2599/2578.Split With Minimum Sum/README.md @@ -10,11 +10,13 @@num1
和 num2
直接连起来,得到 num
各数位的一个排列。
+
num1
和 num2
中所有数字出现的次数之和等于 num
中所有数字出现的次数。num1
和 num2
可以包含前导 0 。请你返回 num1
和 num2
可以得到的和的 最小 值。
输入:num = 4325 输出:59 -解释:我们可以将 4325 分割成num1
= 24 和 num2=
35 ,和为 59 ,59 是最小和。 +解释:我们可以将 4325 分割成num1
= 24 和num2
= 35 ,和为 59 ,59 是最小和。
示例 2:
diff --git a/solution/2500-2599/2578.Split With Minimum Sum/README_EN.md b/solution/2500-2599/2578.Split With Minimum Sum/README_EN.md index f884c082edb21..0364bfbfc5107 100644 --- a/solution/2500-2599/2578.Split With Minimum Sum/README_EN.md +++ b/solution/2500-2599/2578.Split With Minimum Sum/README_EN.md @@ -8,11 +8,13 @@num1
and num2
is a permutation of num
.
+
num1
and num2
is equal to the number of occurrences of that digit in num
.num1
and num2
can contain leading zeros.Return the minimum possible sum of num1
and num2
.
chars
中,那么它的价值是它在字母表中的位置(下标从 1 开始)。
+
'a'
的价值为 1
,'b'
的价值为 2
,以此类推,'z'
的价值为 26
。chars
中的位置为 i
,那么它的价值就是 vals[i]
。请你返回字符串 s
的所有子字符串中的最大开销。
chars
, then its value is its corresponding position (1-indexed) in the alphabet.
+
'a'
is 1
, the value of 'b'
is 2
, and so on. The value of 'z'
is 26
.i
is the index where the character occurs in the string chars
, then its value is vals[i]
.Return the maximum cost among all substrings of the string s
.
现给定一个函数 fn
,一个参数数组 args
和一个时间间隔 t
,返回一个取消函数 cancelFn
。
函数 fn
应该立即使用 args
调用,并且在每个 t
毫秒内再次调用,直到调用 cancelFn
。
在经过 cancelTimeMs
毫秒的延迟后,将调用返回的取消函数 cancelFn
。
+setTimeout(cancelFn, cancelTimeMs) ++ +
函数 fn
应立即使用参数 args
调用,然后每隔 t
毫秒调用一次,直到在 cancelTimeMs
毫秒时调用 cancelFn
。
@@ -26,23 +32,9 @@ {"time": 175, "returned": 8} ] 解释: -const result = [] -const fn = (x) => x * 2 -const args = [4], t = 35, cancelT = 190 - -const start = performance.now() - -const log = (...argsArr) => { - const diff = Math.floor(performance.now() - start) - result.push({"time": diff, "returned": fn(...argsArr)}) -} - -const cancel = cancellable(log, [4], 35); -setTimeout(cancel, 190); - -setTimeout(() => { - console.log(result) // Output - }, cancelT + t + 15) +const cancelTimeMs = 190; +const cancelFn = cancellable((x) => x * 2, [4], 35); +setTimeout(cancelFn, cancelTimeMs); 每隔 35ms,调用 fn(4)。直到 t=190ms,然后取消。 第一次调用 fn 是在 0ms。fn(4) 返回 8。 @@ -68,8 +60,9 @@ setTimeout(() => { {"time": 150, "returned": 10} ] 解释: -const cancel = cancellable((x1, x2) => (x1 * x2), [2, 5], 30); -setTimeout(cancel, 165); +const cancelTimeMs = 165; +const cancelFn = cancellable((x1, x2) => (x1 * x2), [2, 5], 30) +setTimeout(cancelFn, cancelTimeMs) 每隔 30ms,调用 fn(2, 5)。直到 t=165ms,然后取消。 第一次调用 fn 是在 0ms @@ -93,8 +86,9 @@ setTimeout(cancel, 165); {"time": 150, "returned": 9} ] 解释: -const cancel = cancellable((x1, x2, x3) => (x1 + x2 + x3), [5, 1, 3], 50); -setTimeout(cancel, cancelT); +const cancelTimeMs = 180; +const cancelFn = cancellable((x1, x2, x3) => (x1 + x2 + x3), [5, 1, 3], 50) +setTimeout(cancelFn, cancelTimeMs) 每隔 50ms,调用 fn(5, 1, 3)。直到 t=180ms,然后取消。 第一次调用 fn 是在 0ms diff --git a/solution/2700-2799/2725.Interval Cancellation/README_EN.md b/solution/2700-2799/2725.Interval Cancellation/README_EN.md index 119857a75e142..0d10ef9d634ee 100644 --- a/solution/2700-2799/2725.Interval Cancellation/README_EN.md +++ b/solution/2700-2799/2725.Interval Cancellation/README_EN.md @@ -6,8 +6,16 @@
Given a function fn
, an array of arguments args
, and an interval time t
, return a cancel function cancelFn
.
After a delay of cancelTimeMs
, the returned cancel function cancelFn
will be invoked.
+setTimeout(cancelFn, cancelTimeMs) ++
The function fn
should be called with args
immediately and then called again every t
milliseconds until cancelFn
is called at cancelTimeMs
ms.
+
Example 1:
diff --git a/solution/2700-2799/2731.Movement of Robots/README.md b/solution/2700-2799/2731.Movement of Robots/README.md index 94c5ed9e43988..4bf8343fd54f7 100644 --- a/solution/2700-2799/2731.Movement of Robots/README.md +++ b/solution/2700-2799/2731.Movement of Robots/README.md @@ -18,9 +18,10 @@i
和 j
的两个机器人,(i,j)
和 (j,i)
视为相同的坐标对。也就是说,机器人视为无差别的。当两个机器人在同一时刻占据相同的位置时,就会相撞。
+例如,如果一个机器人位于位置 0 并往右移动,另一个机器人位于位置 2 并往左移动,下一秒,它们都将占据位置 1,并改变方向。再下一秒钟后,第一个机器人位于位置 0 并往左移动,而另一个机器人位于位置 2 并往右移动。
@@ -30,6 +31,7 @@diff --git a/solution/2700-2799/2738.Count Occurrences in Text/README.md b/solution/2700-2799/2738.Count Occurrences in Text/README.md index 02bdfab074eee..62ff8c7789928 100644 --- a/solution/2700-2799/2738.Count Occurrences in Text/README.md +++ b/solution/2700-2799/2738.Count Occurrences in Text/README.md @@ -21,9 +21,9 @@ file_name 为该表的主键(具有唯一值的列)。
-
编写解决方案,找出单词 'bull' 和 'bear' 作为 独立词 出现的次数,不考虑任何它出现在两侧没有空格的情况(例如,'bullet', 'bears', 'bull.',或者 'bear' 在句首或句尾 不会 被考虑)。
+编写解决方案,找出单词 'bull' 和 'bear' 作为 独立词 有出现的文件数量,不考虑任何它出现在两侧没有空格的情况(例如,'bullet', 'bears', 'bull.',或者 'bear' 在句首或句尾 不会 被考虑)。
-返回单词 'bull' 和 'bear' 以及它们对应的出现次数,顺序没有限制 。
+返回单词 'bull' 和 'bear' 以及它们对应的出现文件数量,顺序没有限制 。
结果的格式如下所示:
@@ -54,8 +54,8 @@ Files 表: | bear | 2 | +------+-------+ 解释: -- 单词 "bull" 在 "draft1.txt" 中出现1次,在 "draft2.txt" 中出现 1 次,在 "draft3.txt" 中出现 1 次。因此,单词 "bull" 的总出现次数为 3 次。 -- 单词 "bear" 在 "draft2.txt" 中出现1次,在 "draft3.txt" 中出现 1 次。因此,单词 "bear" 的总出现次数为 2 次。 +- 单词 "bull" 在 "draft1.txt" 中出现1次,在 "draft2.txt" 中出现 1 次,在 "draft3.txt" 中出现 1 次。因此,单词 "bull" 出现在 3 个文件中。 +- 单词 "bear" 在 "draft2.txt" 中出现1次,在 "draft3.txt" 中出现 1 次。因此,单词 "bear" 出现在 2 个文件中。 ## 解法 diff --git a/solution/2700-2799/2765.Longest Alternating Subarray/README.md b/solution/2700-2799/2765.Longest Alternating Subarray/README.md index 0be4ed8dddba2..685ad999fc9ed 100644 --- a/solution/2700-2799/2765.Longest Alternating Subarray/README.md +++ b/solution/2700-2799/2765.Longest Alternating Subarray/README.md @@ -1,4 +1,4 @@ -# [2765. 最长交替子序列](https://leetcode.cn/problems/longest-alternating-subarray) +# [2765. 最长交替子数组](https://leetcode.cn/problems/longest-alternating-subarray) [English Version](/solution/2700-2799/2765.Longest%20Alternating%20Subarray/README_EN.md) @@ -6,7 +6,7 @@ -给你一个下标从 0 开始的整数数组 nums
。如果 nums
中长度为 m
的子数组 s
满足以下条件,我们称它是一个 交替子序列 :
给你一个下标从 0 开始的整数数组 nums
。如果 nums
中长度为 m
的子数组 s
满足以下条件,我们称它是一个 交替子数组 :
m
大于 1
。示例 2:
-输入:words = ["$easy$","$problem$"], separator = "$" +输入:words = ["$easy$","$problem$"], separator = "$" 输出:["easy","problem"] 解释:在本示例中,我们进行下述拆分: -"$easy$" 拆分为 "easy"(不包括空字符串) -"$problem$" 拆分为 "problem"(不包括空字符串) +"$easy$" 拆分为 "easy"(不包括空字符串) +"$problem$" 拆分为 "problem"(不包括空字符串) 因此,结果数组为 ["easy","problem"] 。@@ -60,8 +60,8 @@
1 <= words.length <= 100
1 <= words[i].length <= 20
words[i]
中的字符要么是小写英文字母,要么就是字符串 ".,|$#@"
中的字符(不包括引号)separator
是字符串 ".,|$#@"
中的某个字符(不包括引号)words[i]
中的字符要么是小写英文字母,要么就是字符串 ".,|$#@"
中的字符(不包括引号)separator
是字符串 ".,|$#@"
中的某个字符(不包括引号)Example 2:
-Input: words = ["$easy$","$problem$"], separator = "$" +Input: words = ["$easy$","$problem$"], separator = "$" Output: ["easy","problem"] Explanation: In this example we split as follows: -"$easy$" splits into "easy" (excluding empty strings) -"$problem$" splits into "problem" (excluding empty strings) +"$easy$" splits into "easy" (excluding empty strings) +"$problem$" splits into "problem" (excluding empty strings) Hence, the resulting array is ["easy","problem"].@@ -56,8 +56,8 @@ Hence, the resulting array is ["easy","problem"].
1 <= words.length <= 100
1 <= words[i].length <= 20
words[i]
are either lowercase English letters or characters from the string ".,|$#@"
(excluding the quotes)separator
is a character from the string ".,|$#@"
(excluding the quotes)words[i]
are either lowercase English letters or characters from the string ".,|$#@"
(excluding the quotes)separator
is a character from the string ".,|$#@"
(excluding the quotes)给定 id
。id
是从函数 customInterval
返回的值。customClearInterval
应该停止在间隔中执行提供的函数 fn
。
注意:在 Node.js 中,setTimeout
和 setInterval
函数返回一个对象,而不是一个数字。
示例 1:
diff --git a/solution/2800-2899/2805.Custom Interval/README_EN.md b/solution/2800-2899/2805.Custom Interval/README_EN.md index 3062c06b2f517..25052afe6b271 100644 --- a/solution/2800-2899/2805.Custom Interval/README_EN.md +++ b/solution/2800-2899/2805.Custom Interval/README_EN.md @@ -12,6 +12,8 @@Given the id
. id
is the returned value from the function customInterval
. customClearInterval
should stop executing provided function fn
at intervals.
Note: The setTimeout
and setInterval
functions in Node.js return an object, not a number.
Example 1:
diff --git a/solution/2900-2999/2955.Number of Same-End Substrings/README.md b/solution/2900-2999/2955.Number of Same-End Substrings/README.md index bdf7cb40c94ac..dd467fba2ca1a 100644 --- a/solution/2900-2999/2955.Number of Same-End Substrings/README.md +++ b/solution/2900-2999/2955.Number of Same-End Substrings/README.md @@ -1,4 +1,4 @@ -# [2955. Number of Same-End Substrings](https://leetcode.cn/problems/number-of-same-end-substrings) +# [2955. 同端子串的数量](https://leetcode.cn/problems/number-of-same-end-substrings) [English Version](/solution/2900-2999/2955.Number%20of%20Same-End%20Substrings/README_EN.md) @@ -6,41 +6,42 @@ -You are given a 0-indexed string s
, and a 2D array of integers queries
, where queries[i] = [li, ri]
indicates a substring of s
starting from the index li
and ending at the index ri
(both inclusive), i.e. s[li..ri]
.
给定一个 下标从0开始 的字符串 s
,以及一个二维整数数组 queries
,其中 queries[i] = [li, ri]
表示 s
中从索引 li
开始到索引 ri
结束的子串(包括两端),即 s[li..ri]
。
Return an array ans
where ans[i]
is the number of same-end substrings of queries[i]
.
返回一个数组 ans
,其中 ans[i]
是 queries[i]
的 同端 子串的数量。
A 0-indexed string t
of length n
is called same-end if it has the same character at both of its ends, i.e., t[0] == t[n - 1]
.
如果一个 下标从0开始 且长度为 n
的字符串 t
两端的字符相同,即 t[0] == t[n - 1]
,则该字符串被称为 同端。
A substring is a contiguous non-empty sequence of characters within a string.
+子串 是一个字符串中连续的非空字符序列。
-
Example 1:
+ +示例 1:
-Input: s = "abcaab", queries = [[0,0],[1,4],[2,5],[0,5]] -Output: [1,5,5,10] -Explanation: Here is the same-end substrings of each query: -1st query: s[0..0] is "a" which has 1 same-end substring: "a". -2nd query: s[1..4] is "bcaa" which has 5 same-end substrings: "bcaa", "bcaa", "bcaa", "bcaa", "bcaa". -3rd query: s[2..5] is "caab" which has 5 same-end substrings: "caab", "caab", "caab", "caab", "caab". -4th query: s[0..5] is "abcaab" which has 10 same-end substrings: "abcaab", "abcaab", "abcaab", "abcaab", "abcaab", "abcaab", "abcaab", "abcaab", "abcaab", "abcaab". -+输入:s = "abcaab", queries = [[0,0],[1,4],[2,5],[0,5]] +输出:[1,5,5,10] +解释:每个查询的同端子串如下: +第一个查询:s[0..0] 是 "a",有 1 个同端子串:"a"。 +第二个查询:s[1..4] 是 "bcaa",有 5 个同端子串:"bcaa", "bcaa", "bcaa", "bcaa", "bcaa"。 +第三个查询:s[2..5] 是 "caab",有 5 个同端子串:"caab", "caab", "caab", "caab", "caab"。 +第四个查询:s[0..5] 是 "abcaab",有 10 个同端子串:"abcaab", "abcaab", "abcaab", "abcaab", "abcaab", "abcaab", "abcaab", "abcaab", "abcaab", "abcaab"。 -
Example 2:
+示例 2:
-Input: s = "abcd", queries = [[0,3]] -Output: [4] -Explanation: The only query is s[0..3] which is "abcd". It has 4 same-end substrings: "abcd", "abcd", "abcd", "abcd". +输入:s = "abcd", queries = [[0,3]] +输出:[4] +解释:唯一的查询是 s[0..3],它有 4 个同端子串:"abcd", "abcd", "abcd", "abcd"。
-
Constraints:
+ +提示:
2 <= s.length <= 3 * 104
s
consists only of lowercase English letters.s
仅包含小写英文字母。1 <= queries.length <= 3 * 104
queries[i] = [li, ri]
0 <= li <= ri < s.length
batteryPercentages[i]
大于 0
:
+
[i + 1, n - 1]
的所有设备的电池百分比减少 1
,确保它们的电池百分比 不会低于 0
,即 batteryPercentages[j] = max(0, batteryPercentages[j] - 1)
。返回一个整数,表示按顺序执行测试操作后 已测试设备 的数量。
diff --git a/solution/2900-2999/2960.Count Tested Devices After Test Operations/README_EN.md b/solution/2900-2999/2960.Count Tested Devices After Test Operations/README_EN.md index 201ca04c69547..d2daa080298d4 100644 --- a/solution/2900-2999/2960.Count Tested Devices After Test Operations/README_EN.md +++ b/solution/2900-2999/2960.Count Tested Devices After Test Operations/README_EN.md @@ -10,6 +10,7 @@batteryPercentages[i]
is greater than 0
:
+
j
in the range [i + 1, n - 1]
by 1
, ensuring their battery percentage never goes below 0
, i.e, batteryPercentages[j] = max(0, batteryPercentages[j] - 1)
.Return an integer denoting the number of devices that will be tested after performing the test operations in order.
diff --git a/solution/2900-2999/2978.Symmetric Coordinates/README.md b/solution/2900-2999/2978.Symmetric Coordinates/README.md index 61f8774596645..14fda796fbffa 100644 --- a/solution/2900-2999/2978.Symmetric Coordinates/README.md +++ b/solution/2900-2999/2978.Symmetric Coordinates/README.md @@ -1,4 +1,4 @@ -# [2978. Symmetric Coordinates](https://leetcode.cn/problems/symmetric-coordinates) +# [2978. 对称坐标](https://leetcode.cn/problems/symmetric-coordinates) [English Version](/solution/2900-2999/2978.Symmetric%20Coordinates/README_EN.md) @@ -6,7 +6,7 @@ -Table: Coordinates
表: Coordinates
+-------------+------+ @@ -15,22 +15,23 @@ | X | int | | Y | int | +-------------+------+ -Each row includes X and Y, where both are integers. Table may contain duplicate values. +每一行包括 X 和 Y,都是整数。表格可能包含重复值。-
Two coordindates (X1, Y1)
and (X2, Y2)
are said to be symmetric coordintes if X1 == Y2
and X2 == Y1
.
如果两个坐标 (X1, Y1)
和 (X2, Y2)
满足条件 X1 == Y2
和 X2 == Y1
,则它们被称为 对称 坐标。
Write a solution that outputs, among all these symmetric coordintes, only those unique coordinates that satisfy the condition X1 <= Y1
.
编写一个解决方案,找出在所有这些对称坐标中,满足条件 X1 <= Y1
的唯一坐标。
Return the result table ordered by X
and Y
(respectively) in ascending order.
按照 X
和 Y
分别 升序 排列结果表。
The result format is in the following example.
+结果格式如下示例所示。
-
Example 1:
+ +示例 1:
-Input: +输入: Coordinates table: +----+----+ | X | Y | @@ -42,7 +43,7 @@ Coordinates table: | 22 | 23 | | 21 | 20 | +----+----+ -Output: +输出: +----+----+ | x | y | +----+----+ @@ -50,11 +51,11 @@ Coordinates table: | 20 | 21 | | 22 | 23 | +----+----+ -Explanation: -- (20, 20) and (20, 20) are symmetric coordinates because, X1 == Y2 and X2 == Y1. This results in displaying (20, 20) as a distinctive coordinates. -- (20, 21) and (21, 20) are symmetric coordinates because, X1 == Y2 and X2 == Y1. However, only (20, 21) will be displayed because X1 <= Y1. -- (23, 22) and (22, 23) are symmetric coordinates because, X1 == Y2 and X2 == Y1. However, only (22, 23) will be displayed because X1 <= Y1. -The output table is sorted by X and Y in ascending order. +解释: +- (20, 20) 和 (20, 20) 是对称坐标,因为 X1 == Y2 和 X2 == Y1。所以 (20, 20) 被显示为独特的坐标。 +- (20, 21) 和 (21, 20) 是对称坐标,因为 X1 == Y2 和 X2 == Y1。然而,只有 (20, 21) 会被显示,因为 X1 <= Y1。 +- (23, 22) 和 (22, 23) 是对称坐标,因为 X1 == Y2 和 X2 == Y1。然而,只有 (22, 23) 会被显示,因为 X1 <= Y1。 +输出表按照 X 和 Y 升序排列。## 解法 diff --git a/solution/2900-2999/2984.Find Peak Calling Hours for Each City/README.md b/solution/2900-2999/2984.Find Peak Calling Hours for Each City/README.md index 5c594a581a41b..18e974f5c1ee7 100644 --- a/solution/2900-2999/2984.Find Peak Calling Hours for Each City/README.md +++ b/solution/2900-2999/2984.Find Peak Calling Hours for Each City/README.md @@ -23,7 +23,7 @@
编写一个查询,找到每个 city
的 高峰 通话 时间。如果 多个时间 有 相同 数量的通话,则所有这些时间都将被视为该特定城市的 高峰时间。
按照 高峰通话时间 和 city
按 降序 排序返回结果表。
按照 高峰时间 和 city
按 降序 排序返回结果表。
结果格式如下例所示。
@@ -56,8 +56,8 @@ Calls table: 对于 Houston: - 高峰时间是 22:00,总共记录了 3 次通话。 对于 New York: - - 3:00 和 14:00 都有相同数量的通话,因此这两个时间都被视为高峰小时。 -输出表按照高峰通话小时和城市按降序排序。 + - 3:00 和 14:00 都有相同数量的通话,因此这两个时间都被视为高峰时间。 +输出表按照高峰时间和城市按降序排序。 ## 解法 diff --git a/solution/2900-2999/2986.Find Third Transaction/README.md b/solution/2900-2999/2986.Find Third Transaction/README.md index 9ae8a13ba8c4d..0ff4cb29199b4 100644 --- a/solution/2900-2999/2986.Find Third Transaction/README.md +++ b/solution/2900-2999/2986.Find Third Transaction/README.md @@ -20,7 +20,7 @@ 该表包含 user_id, spend,和 transaction_date。 -编写一个查询,找到每个用户的 第三笔交易 (如果他们有至少三笔交易),其中 前两笔交易 的花费 低于 第三笔交易的花费。
+编写一个查询,找到符合要求的用户的 第三笔交易 (如果他们有至少三笔交易),并且满足 前两笔交易 的花费 低于 第三笔交易的花费。
返回 按 升序 user_id
排序的结果表。
编写一个查询,计算学生获得的 最高分 和 最低分 之间的 总分差(3
次作业的总和)。
编写一个查询,计算学生获得的 最高总分 和 最低总分 之间的 差(3
次作业的总和)。
以 任意 顺序返回结果表。
@@ -58,7 +58,7 @@ Scores 表: - student_id 423 的总分为 60 + 44 + 47 = 151。 - student_id 896 的总分为 32 + 37 + 50 = 119。 - student_id 235 的总分为 31 + 53 + 69 = 153。 -student_id 321 的最高分为 230,而 student_id 896 的最低分为 119。因此,它们之间的差异为 111。 +student_id 321 拥有最高分为 230,而 student_id 896 拥有最低分为 119。因此,它们之间的差异为 111。 ## 解法 diff --git a/solution/2900-2999/2990.Loan Types/README.md b/solution/2900-2999/2990.Loan Types/README.md index f9c80c85f8808..331f8e4d518fe 100644 --- a/solution/2900-2999/2990.Loan Types/README.md +++ b/solution/2900-2999/2990.Loan Types/README.md @@ -20,7 +20,7 @@ loan_id 是这张表具有唯一值的列。 该表包含 loan_id, user_id,和 loan_type。 -编写一个查询,找到所有至少有一种 Refinance 贷款类型和至少有一种 Mortgage 贷款类型的 不同 user_id
。
编写一个解决方案,找出所有具有至少一种 再融资 贷款类型和至少一种 抵押 贷款类型的 不同的 user_id
。
按 升序 返回结果表中的 user_id
。
编写一个查询来找到 每个国家前三家 基于它们的 总分数 的 酒庄。如果 多个酒庄 具有 相同 的总分数,则按 升序 排列它们的 winery
名称。如果 没有第二家酒庄,则输出 'No Second Winery',如果 没有第三家酒庄,则输出 'No Third Winery'。
编写一个解决方案,根据每家酒庄的 总分 找出 每个国家 的 前三名酒庄。如果有 多个酒庄 的总分 相同,则按 winery
名称升序排列。如果没有 分数排在第二的酒庄,则输出 'No Second Winery',如果没有 分数排在第三的酒庄,则输出 'No Third Winery'。
返回结果表按 country
升序 排列。
给定一个整数 n
,返回 下标从 1 开始 的数组 nums = [1, 2, ..., n]
的 排列数,使其满足 自整除 条件。
给定一个整数 n
,返回 下标从 1 开始 的数组 nums = [1, 2, ..., n]
的 可能的排列组合数量,使其满足 自整除 条件。
如果对于每个 1 <= i <= n
,至少 满足以下条件之一,数组 nums
就是 自整除 的:
如果对于每个 1 <= i <= n
,满足 gcd(a[i], i) == 1
,数组 nums
就是 自整除 的。
nums[i] % i == 0
i % nums[i] == 0
数组的 排列 是对数组元素的重新排列的数量,例如,下面是数组 [1, 2, 3]
的所有排列:
数组的 排列 是对数组元素的重新排列组合,例如,下面是数组 [1, 2, 3]
的所有排列组合:
[1, 2, 3]
输入:n = 2 -输出:2 -解释:数组 [1,2] 有 2 个排列,都是自整除的: -nums = [1,2]:这是自整除的,因为 nums[1] % 1 == 0 和 nums[2] % 2 == 0。 -nums = [2,1]:这是自整除的,因为 nums[1] % 1 == 0 和 2 % nums[2] == 0。 +输出:1 +解释:数组 [1,2] 有 2 个排列,但只有其中一个是自整除的: +nums = [1,2]:这不是自整除的,因为 gcd(nums[2], 2) != 1。 +nums = [2,1]:这是自整除的,因为 gcd(nums[1], 1) == 1 并且 gcd(nums[2], 2) == 1。
示例 3:
@@ -60,7 +55,7 @@ nums = [2,1]:这是自整除的,因为 nums[1] % 1 == 0 和 2 % nums[2] == 0提示:
1 <= n <= 15
1 <= n <= 12
Table: Purchases
表: Purchases
+---------------+------+ @@ -16,22 +16,23 @@ | purchase_date | date | | amount_spend | int | +---------------+------+ -(user_id, purchase_date, amount_spend) is the primary key (combination of columns with unique values) for this table. -purchase_date will range from November 1, 2023, to November 30, 2023, inclusive of both dates. -Each row contains user id, purchase date, and amount spend. +(user_id, purchase_date, amount_spend) 是该表的主键(具有唯一值的列)。 +purchase_date 的范围从 2023 年 11 月 1 日到 2023 年 11 月 30 日,并包括这两个日期。 +每一行包含 user id, purchase date,和 amount spend。-
Write a solution to calculate the total spending by users on each Friday of every week in November 2023. Output only weeks that include at least one purchase on a Friday.
+编写一个解决方案,计算用户在 2023 年 11 月 的 每个星期五 的 总花费。输出所有在 周五 有购买记录的周。
-Return the result table ordered by week of month in ascending order.
+按照每月的周次序 升序 排列结果表。
-The result format is in the following example.
+结果格式如下示例所示。
-
Example 1:
+ +示例 1:
-Input: +输入: Purchases table: +---------+---------------+--------------+ | user_id | purchase_date | amount_spend | @@ -45,19 +46,19 @@ Purchases table: | 10 | 2023-11-12 | 8266 | | 13 | 2023-11-24 | 12000 | +---------+---------------+--------------+ -Output: +输出: +---------------+---------------+--------------+ | week_of_month | purchase_date | total_amount | +---------------+---------------+--------------+ | 1 | 2023-11-03 | 5117 | | 4 | 2023-11-24 | 21692 | +---------------+---------------+--------------+ -Explanation: -- During the first week of November 2023, transactions amounting to $5,117 occurred on Friday, 2023-11-03. -- For the second week of November 2023, there were no transactions on Friday, 2023-11-10. -- Similarly, during the third week of November 2023, there were no transactions on Friday, 2023-11-17. -- In the fourth week of November 2023, two transactions took place on Friday, 2023-11-24, amounting to $12,000 and $9,692 respectively, summing up to a total of $21,692. -Output table is ordered by week_of_month in ascending order.+解释: +- 在 2023 年 11 月的第一周,于 2023-11-03 星期五发生了总额为 $5,117 的交易。 +- 对于 2023 年 11 月的第二周,于 2023-11-10 星期五没有交易。 +- 同样,在 2023 年 11 月的第三周,于 2023-11-17 星期五没有交易。 +- 在 2023 年 11 月的第四周,于 2023-11-24 星期五发生了两笔交易,分别为 $12,000 和 $9,692,总计为 $21,692。 +输出表按照 week_of_month 升序排列。 ## 解法 diff --git a/solution/2900-2999/2994.Friday Purchases II/README.md b/solution/2900-2999/2994.Friday Purchases II/README.md index b2418f0de26bc..774f8f1f36632 100644 --- a/solution/2900-2999/2994.Friday Purchases II/README.md +++ b/solution/2900-2999/2994.Friday Purchases II/README.md @@ -1,4 +1,4 @@ -# [2994. Friday Purchases II](https://leetcode.cn/problems/friday-purchases-ii) +# [2994. 发生在周五的交易 II](https://leetcode.cn/problems/friday-purchases-ii) [English Version](/solution/2900-2999/2994.Friday%20Purchases%20II/README_EN.md) @@ -6,7 +6,7 @@ -
Table: Purchases
表: Purchases
+---------------+------+ @@ -16,22 +16,24 @@ | purchase_date | date | | amount_spend | int | +---------------+------+ -(user_id, purchase_date, amount_spend) is the primary key (combination of columns with unique values) for this table. -purchase_date will range from November 1, 2023, to November 30, 2023, inclusive of both dates. -Each row contains user id, purchase date, and amount spend. -+(user_id, purchase_date, amount_spend) 是该表的主键(具有唯一值的列)。 +purchase_date 的范围从 2023 年 11 月 1 日到 2023 年 11 月 30 日,并包括这两个日期。 +每一行包含 user id, purchase date,和 amount spend。 -
Write a solution to calculate the total spending by users on each Friday of every week in November 2023. If there are no purchases on a particular Friday of a week, it will be considered as 0
.
编写一个解决方案,计算用户在 2023 年 11 月的 每个星期五 的 总花费。如果在 某个星期的星期五 没有 购买记录,则将其视为花费金额为 0
。
Return the result table ordered by week of month in ascending order.
+ -The result format is in the following example.
+按照每月的周次序 升序 排列结果表。
+ +结果格式如下示例所示。
-
Example 1:
+ +示例 1:
-Input: +输入: Purchases table: +---------+---------------+--------------+ | user_id | purchase_date | amount_spend | @@ -45,7 +47,7 @@ Purchases table: | 10 | 2023-11-12 | 8266 | | 13 | 2023-11-24 | 12000 | +---------+---------------+--------------+ -Output: +输出: +---------------+---------------+--------------+ | week_of_month | purchase_date | total_amount | +---------------+---------------+--------------+ @@ -54,12 +56,12 @@ Purchases table: | 3 | 2023-11-17 | 0 | | 4 | 2023-11-24 | 21692 | +---------------+---------------+--------------+ -Explanation: -- During the first week of November 2023, transactions amounting to $5,117 occurred on Friday, 2023-11-03. -- For the second week of November 2023, there were no transactions on Friday, 2023-11-10, resulting in a value of 0 in the output table for that day. -- Similarly, during the third week of November 2023, there were no transactions on Friday, 2023-11-17, reflected as 0 in the output table for that specific day. -- In the fourth week of November 2023, two transactions took place on Friday, 2023-11-24, amounting to $12,000 and $9,692 respectively, summing up to a total of $21,692. -Output table is ordered by week_of_month in ascending order.+解释: +- 在 2023 年 11 月的第一周的周五(即 2023-11-03),共发生了总计 $5,117 的交易。 +- 在 2023 年 11 月的第二周的周五(即 2023-11-10),当天没有交易,因此在输出表中该天的值为 0。 +- 类似地,在 2023 年 11 月的第三周的周五(即 2023-11-17),当天没有交易,因此在输出表中该天的值为 0。 +- 在 2023 年 11 月的第四周的周五(即 2023-11-24),当天发生了两笔交易,分别为 $12,000 和 $9,692,总计 $21,692。 +输出表按照 week_of_month 按升序排序。 ## 解法 diff --git a/solution/2900-2999/2995.Viewers Turned Streamers/README.md b/solution/2900-2999/2995.Viewers Turned Streamers/README.md index 0ac0d892329e7..e13b43dbfa36e 100644 --- a/solution/2900-2999/2995.Viewers Turned Streamers/README.md +++ b/solution/2900-2999/2995.Viewers Turned Streamers/README.md @@ -23,7 +23,7 @@ session_type 是一个 ENUM (枚举) 类型,包含(Viewer, Streamer)两个类 这张表包含 user id, session start, session end, session id 和 session type。 -
编写一个解决方案,找到 首次会话 为 观众 的用户的 会话 数量。
+编写一个解决方案,找到 首次会话 为 观众身份 的用户,其 主播会话 数量。
按照会话数量和 user_id
降序 排序返回结果表。
现有一个下标从 0 开始的 8 x 8
棋盘,上面有 3
枚棋子。
现有一个下标从 1 开始的 8 x 8
棋盘,上面有 3
枚棋子。
给你 6
个整数 a
、b
、c
、d
、e
和 f
,其中:
You are given a 2D integer array edges
representing a tree with n
nodes, numbered from 0
to n - 1
, rooted at node 0
, where edges[i] = [ui, vi]
means there is an edge between the nodes vi
and ui
.
给定一个二维整数数组 edges
,表示一个有 n
个节点的树,节点编号从 0
到 n - 1
,以节点 0
为根,其中 edges[i] = [ui, vi]
表示节点 vi
和 ui
之间存在一条边。
You are also given a 0-indexed integer array colors
of size n
, where colors[i]
is the color assigned to node i
.
还给定一个 下标从 0 开始,大小为 n
的整数数组 colors
,其中 colors[i]
表示节点 i
分配的颜色。
We want to find a node v
such that every node in the subtree of v
has the same color.
我们希望找到一个节点 v
,使得 v
的子树中的每个节点具有 相同 的颜色。
Return the size of such subtree with the maximum number of nodes possible.
+返回 具有 尽可能多 节点 且 符合上述要求的子树大小。
+
Example 1:
+示例 1:
-Input: edges = [[0,1],[0,2],[0,3]], colors = [1,1,2,3] -Output: 1 -Explanation: Each color is represented as: 1 -> Red, 2 -> Green, 3 -> Blue. We can see that the subtree rooted at node 0 has children with different colors. Any other subtree is of the same color and has a size of 1. Hence, we return 1. +输入:edges = [[0,1],[0,2],[0,3]], colors = [1,1,2,3] +输出:1 +解释:每种颜色分别对应为:1 -> 红色,2 -> 绿色,3 -> 蓝色。我们可以看到以节点 0 为根的子树具有不同颜色的子节点。任何其他子树都是相同颜色的,并且大小为 1。因此,我们返回 1。-
Example 2:
+示例 2:
-Input: edges = [[0,1],[0,2],[0,3]], colors = [1,1,1,1] -Output: 4 -Explanation: The whole tree has the same color, and the subtree rooted at node 0 has the most number of nodes which is 4. Hence, we return 4. +输入:edges = [[0,1],[0,2],[0,3]], colors = [1,1,1,1] +输出:4 +解释:整个树具有相同的颜色,以节点 0 为根的子树具有节点数最多,为 4。因此,我们返回 4。
Example 3:
+示例 3:
-Input: edges = [[0,1],[0,2],[2,3],[2,4]], colors = [1,2,3,3,3] -Output: 3 -Explanation: Each color is represented as: 1 -> Red, 2 -> Green, 3 -> Blue. We can see that the subtree rooted at node 0 has children with different colors. Any other subtree is of the same color, but the subtree rooted at node 2 has a size of 3 which is the maximum. Hence, we return 3. +输入:edges = [[0,1],[0,2],[2,3],[2,4]], colors = [1,2,3,3,3] +输出:3 +解释:每种颜色分别对应为:1 -> 红色,2 -> 绿色,3 -> 蓝色。我们可以看到以节点 0 为根的子树有不同颜色的子节点。其他任何子树都是相同颜色的,但以节点 2 为根的子树的大小为 3,这是最大的。因此,我们返回 3。
-
Constraints:
+ +提示:
n == edges.length + 1
0 <= ui, vi < n
colors.length == n
1 <= colors[i] <= 105
edges
is a tree.edges
表示的图是一棵树。