当前位置:网站首页>LeetCode Daily 2 Questions 01: Reverse Strings (both 1200) Method: Double Pointer
LeetCode Daily 2 Questions 01: Reverse Strings (both 1200) Method: Double Pointer
2022-08-10 22:29:00 【The man was fishing for snow in the cold river alone.】
The title is as follows:
Method:
Solution idea: Use the double pointer method to determine the left value left and the right value right of the array, and then exchange the two-digit numbers. After each cycle, the left is shifted to the right, and the right is shifted to the left,
class Solution {public void reverseString(char[] s) {int left=0,h=(s.length-1)/2,right=s.length-1;while (left<=h){//0<2char temp=s[left];s[left]=s[right];s[right]=temp;left++;right--;}}}
边栏推荐
- Why general company will say "go back messages such as" after the end of the interview, rather than just tell the interviewer the result?
- 【PCBA scheme design】Bluetooth skipping scheme
- 管理员必须知道的RADIUS认证服务器的部署成本
- Service - DNS forward and reverse domain name resolution service
- 过滤器
- 学会开会|成为有连接感组织的重要技能
- Shell 编程--Sed
- About DataFrame: Processing Time
- Thread State 详解
- labelme-5.0.1版本编辑多边形闪退
猜你喜欢
随机推荐
Likou 215 questions, the Kth largest element in an array
高通平台开发系列讲解(应用篇)QCMAP应用框架介绍
BM7 链表中环的入口结点
shell脚本循环语句for、while语句
这些不可不知的JVM知识,我都用思维导图整理好了
LeetCode Daily Question (1573. Number of Ways to Split a String)
IM 即时通讯开发如何设计图片文件的服务端存储架构
mmpose关键点(一):评价指标(PCK,OKS,mAP)
unusual understanding
camera preview process --- from HAL to OEM
[SQL brush questions] Day3----Special exercises for common functions that SQL must know
Thread State 详解
【SQL刷题】Day3----SQL必会的常用函数专项练习
VLAN huawei 三种模式
翻译科技论文,俄译中怎样效果好
基于交流潮流的电力系统多元件N-k故障模型研究(Matlab代码实现)【电力系统故障】
华为HCIE云计算之Fusion Access桌面云
STL-stack
学会开会|成为有连接感组织的重要技能
阿里云新增三大高性能计算解决方案,助力生命科学行业快速发展