当前位置:网站首页>LeetCode 344. Reverse string
LeetCode 344. Reverse string
2022-07-01 09:13:00 【Ashby's daily life】
https://leetcode-cn.com/problems/reverse-string/
Ideas :
- Double pointer , Head pointer and tail pointer
- When the head pointer index is smaller than the tail pointer index , Exchange value
/** * Double pointer * @param s */
public void reverseString(char[] s) {
int first = 0;
int last = s.length - 1;
while (first < last) {
char tmp = s[first];
s[first] = s[last];
s[last] = tmp;
first++;
last--;
}
}
边栏推荐
- Latex插入的eps图片模糊解决方法
- Serialization, listening, custom annotation
- Shell script case in statement
- 【检测技术课案】简易数显电子秤的设计与制作
- Class loading
- Shell脚本-case in 和正则表达式
- How to launch circle of friends marketing and wechat group activities
- Why is the Ltd independent station a Web3.0 website!
- 树结构---二叉树2非递归遍历
- Input标签的type设置为number,去掉上下箭头
猜你喜欢
Principles of Microcomputer - internal and external structure of microprocessor
樹結構---二叉樹2非遞歸遍曆
Jetson nano installs tensorflow GPU and problem solving
2.4 activation function
Bird recognition app
Football and basketball game score live broadcast platform source code /app development and construction project
jeecg 重启报40001
[interview brush 101] linked list
Performance improvement 2-3 times! The second generation Kunlun core server of Baidu AI Cloud was launched
Tree structure -- binary tree 2 non recursive traversal
随机推荐
Understand shallow replication and deep replication through code examples
How to solve the problem of fixed assets management and inventory?
pcl_viewer命令
毕业季,我想对你说
LogBack
韦东山板子编译内核问题解决
Ranking list of domestic databases in February, 2022: oceanbase regained the "three consecutive increases", and gaussdb is expected to achieve the largest increase this month
易点易动助力企业设备高效管理,提升设备利用率
[ESP nanny level tutorial] crazy completion chapter - Case: ws2812 light control system based on Alibaba cloud, applet and Arduino
Leetcode daily question brushing record --540 A single element in an ordered array
Promise asynchronous programming
Tree structure -- binary tree 2 non recursive traversal
Shell脚本-while循环详解
Jetson Nano 安装TensorFlow GPU及问题解决
【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + DS18B20温度传感器 +NodeJs本地服务+ MySQL数据库
通过 代码实例 理解 浅复制 与 深复制
Day06 branch structure and cycle (III)
2.3 【kaggle数据集 - dog breed 举例】数据预处理、重写Dataset、DataLoader读取数据
Daily office consumables management solution
SDN_简单总结