大家好,我是毛毛。ヾ(´∀ ˋ)ノ
废话不多说开始今天的解题Day~
Write a function that reverses a string. The input string is given as an array of characters s
.
Input: s = ["h","e","l","l","o"]
Output: ["o","l","l","e","h"]
Input: s = ["H","a","n","n","a","h"]
Output: ["h","a","n","n","a","H"]
1 <= s.length <= 10^5
s[i]
is a printable ascii character.首先先简单的翻译一下题目
给一个Strings
,把这个String用in-place
的方式做reverse。
作法大致上是这样
low
跟high
两个index指向String的头跟尾,然後互换就这样XD。class Solution:
def reverseString(self, s: List[str]) -> None:
"""
Do not return anything, modify s in-place instead.
"""
low = 0
high = len(s)-1
while low<=high:
s[low], s[high] = s[high], s[low]
low += 1
high -= 1
void reverseString(char* s, int sSize){
int low = 0;
int high = sSize-1;
int tmp;
while (low<=high){
tmp = s[low];
s[low] = s[high];
s[high] = tmp;
low++;
high--;
}
}
Python
C
大家明天见
Guard 可以帮助你在开发时监听,并启用测试,让你在开发阶段可以顺便跑测试,当然我也是第一次玩XD...
最近读到从 Sr. 工程师转成工程师主管的的经验,作者同时也分享自己的阅读清单。看了一下阅读清单,经...
各位先备好 如果有一个excel里面资料大概有50列,而每一行都是记载着不同的资讯,譬如:姓名/电话...
终於完成三十天份量的文章了!!! 虽然蓝牙对我来说是一个已经认识一年多的主题 但是在撰写内容时还是觉...
根据相对论,如果一对挛生兄弟, 哥哥搭乘宇宙飞船,以接近光速,飞离地球,在宇宙间航行; 当回到地球的...