Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2a8c571

Browse files
Merge pull request youngyangyang04#2333 from qiu121/master
📝 Update 0383.赎金信.md with python3 && 📝 Update 0344.反转字符串.md with python3
2 parents 5258b75 + ce2ffd0 commit 2a8c571

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

‎problems/0344.反转字符串.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,20 @@ class Solution:
250250
s[:] = [s[i] for i in range(len(s) - 1, -1, -1)]
251251

252252
```
253+
254+
(版本七) 使用reverse()
255+
256+
```python
257+
class Solution:
258+
def reverseString(self, s: List[str]) -> None:
259+
"""
260+
Do not return anything, modify s in-place instead.
261+
"""
262+
# 原地反转,无返回值
263+
s.reverse()
264+
265+
```
266+
253267
### Go:
254268

255269
```Go

‎problems/0383.赎金信.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,19 @@ class Solution:
214214
return all(ransomNote.count(c) <= magazine.count(c) for c in set(ransomNote))
215215
```
216216

217+
(版本六)使用count(简单易懂)
218+
219+
```python3
220+
class Solution:
221+
def canConstruct(self, ransomNote: str, magazine: str) -> bool:
222+
for char in ransomNote:
223+
if char in magazine and ransomNote.count(char) <= magazine.count(char):
224+
continue
225+
else:
226+
return False
227+
return True
228+
```
229+
217230
### Go:
218231
219232
```go

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /