mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-06 17:44:10 +08:00
Update 1816 solution
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
# [1816. Truncate Sentence](https://leetcode-cn.com/problems/truncate-sentence/)
|
||||
# [1816. Truncate Sentence](https://leetcode.com/problems/truncate-sentence/)
|
||||
|
||||
## 题目
|
||||
|
||||
@ -49,8 +49,8 @@ You are given a sentence s and an integer k. You want to truncate s such that it
|
||||
|
||||
## 解题思路
|
||||
|
||||
- 遍历字符串s,找到最后一个空格的下标end
|
||||
- 如果end为0,直接返回s,否则返回s[:end]
|
||||
- 遍历字符串 s,找到最后一个空格的下标 end
|
||||
- 如果 end 为 0,直接返回 s,否则返回 s[:end]
|
||||
|
||||
## 代码
|
||||
|
||||
|
Reference in New Issue
Block a user