mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 15:31:43 +08:00
移除零宽空格
This commit is contained in:
@@ -16,13 +16,13 @@
|
||||
<pre>
|
||||
<strong>Input:</strong> s = "11111222223", k = 3
|
||||
<strong>Output:</strong> "135"
|
||||
<strong>Explanation:</strong>
|
||||
<strong>Explanation:</strong>
|
||||
- For the first round, we divide s into groups of size 3: "111", "112", "222", and "23".
|
||||
Then we calculate the digit sum of each group: 1 + 1 + 1 = 3, 1 + 1 + 2 = 4, 2 + 2 + 2 = 6, and 2 + 3 = 5.
|
||||
Then we calculate the digit sum of each group: 1 + 1 + 1 = 3, 1 + 1 + 2 = 4, 2 + 2 + 2 = 6, and 2 + 3 = 5.
|
||||
So, s becomes "3" + "4" + "6" + "5" = "3465" after the first round.
|
||||
- For the second round, we divide s into "346" and "5".
|
||||
Then we calculate the digit sum of each group: 3 + 4 + 6 = 13, 5 = 5.
|
||||
So, s becomes "13" + "5" = "135" after second round.
|
||||
Then we calculate the digit sum of each group: 3 + 4 + 6 = 13, 5 = 5.
|
||||
So, s becomes "13" + "5" = "135" after second round.
|
||||
Now, s.length <= k, so we return "135" as the answer.
|
||||
</pre>
|
||||
|
||||
@@ -31,9 +31,9 @@ Now, s.length <= k, so we return "135" as the answer.
|
||||
<pre>
|
||||
<strong>Input:</strong> s = "00000000", k = 3
|
||||
<strong>Output:</strong> "000"
|
||||
<strong>Explanation:</strong>
|
||||
<strong>Explanation:</strong>
|
||||
We divide s into "000", "000", and "00".
|
||||
Then we calculate the digit sum of each group: 0 + 0 + 0 = 0, 0 + 0 + 0 = 0, and 0 + 0 = 0.
|
||||
Then we calculate the digit sum of each group: 0 + 0 + 0 = 0, 0 + 0 + 0 = 0, and 0 + 0 = 0.
|
||||
s becomes "0" + "0" + "0" = "000", whose length is equal to k, so we return "000".
|
||||
</pre>
|
||||
|
||||
|
Reference in New Issue
Block a user