File tree Expand file tree Collapse file tree 5 files changed +27
-0
lines changed
Expand file tree Collapse file tree 5 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 99| [ LeetCode-数组] ( ./leetcode_array/main.md ) | leetcode数组类算法练习|
1010| [ LeetCode-链表] ( ./leetcode_linked_list/main.md ) | leetcode链表类算法练习|
1111| [ LeetCode-哈希表] ( ./leetcode_hash/main.md ) | leetcode哈希表类算法练习|
12+ | [ LeetCode-字符串] ( ./leetcode_string/main.md ) | leetcode字符串类算法练习|
1213| [ LeetCode-栈] ( ./leetcode_stack/main.md ) | leetcode栈类算法练习|
1314| [ LeetCode-树] ( ./leetcode_tree/main.md ) | leetcode树类算法练习|
1415| [ Django学习] ( ./django_note/main.md ) | Django学习笔记。|
Original file line number Diff line number Diff line change 1313* [ 螺旋矩阵II] ( 螺旋矩阵2.md )
1414* [ 三数之和(左右指针)] ( 三数之和.md )
1515* [ 四数之和] ( 四数之和.md )
16+ * [ 反转字符串(双指针)] ( 反转字符串.md )
1617
1718<!--
18192. [删除排序数组中的重复项](删除排序数组中的重复项.md)
Original file line number Diff line number Diff line change 1+ # 344.反转字符串
2+ ## 题目
3+ 编写一个函数,其作用是将输入的字符串反转过来。输入字符串以字符数组 char[ ] 的形式给出。
4+
5+ 不要给另外的数组分配额外的空间,你必须原地修改输入数组、使用 O(1) 的额外空间解决这一问题。
6+ ``` python
7+ 输入:[" h" ," e" ," l" ," l" ," o" ]
8+ 输出:[" o" ," l" ," l" ," e" ," h" ]
9+ ```
10+
11+ ## 分析
12+ ![ ] ( ../pic/leetcode_array/344_1.png )
13+ * 左右两个指针分别从数组两端向中间运动,并交换两个指针对应的值
14+
15+ ``` python
16+ class Solution :
17+ def reverseString (self , s : List[str ]) -> None :
18+ L = 0
19+ R = len (s) - 1
20+ while L < R:
21+ s[L], s[R] = s[R], s[L]
22+ L += 1
23+ R -= 1
24+ ```
Original file line number Diff line number Diff line change 1+ # 字符串
You can’t perform that action at this time.
0 commit comments