LeetCode 344. Reverse String
Problem:
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
此题一般思路为:在原数组上直接对s[i]以及s[len-i-1]进行调换即可。
char* reverseString(char* s) {
int i = , len = ;
len = strlen(s);
for (i = ; i < len / ; i++) {
int tmp = s[i];
s[i] = s[len - i - ];
s[len - i - ] = tmp;
}
return s;
}
LeetCode 344. Reverse String的更多相关文章
- [LeetCode] 344 Reverse String && 541 Reverse String II
原题地址: 344 Reverse String: https://leetcode.com/problems/reverse-string/description/ 541 Reverse Stri ...
- Leetcode#344. Reverse String(反转字符串)
题目描述 编写一个函数,其作用是将输入的字符串反转过来. 示例 1: 输入: "hello" 输出: "olleh" 示例 2: 输入: "A man ...
- leetcode 344. Reverse String 、541. Reverse String II 、796. Rotate String
344. Reverse String 最基础的旋转字符串 class Solution { public: void reverseString(vector<char>& s) ...
- LeetCode 344. Reverse String(反转字符串)
题目描述 LeetCode 344. 反转字符串 请编写一个函数,其功能是将输入的字符串反转过来. 示例 输入: s = "hello" 返回: "olleh" ...
- [LeetCode] 344. Reverse String 翻转字符串
Write a function that reverses a string. The input string is given as an array of characters char[]. ...
- Leetcode 344 Reverse String 字符串处理
题意:反转字符串,用好库函数. class Solution { public: string reverseString(string s) { reverse(s.begin(),s.end()) ...
- Python [Leetcode 344]Reverse String
题目描述: Write a function that takes a string as input and returns the string reversed. Example:Given s ...
- (字符串 数组 递归 双指针) leetcode 344. Reverse String
Write a function that reverses a string. The input string is given as an array of characters char[]. ...
- LeetCode Javascript实现 344. Reverse String 292. Nim Game 371. Sum of Two Integers
344. Reverse String /** * @param {string} s * @return {string} */ var reverseString = function(s) { ...
随机推荐
- html5第二天
哎..以为自己能每天坚持写呢.前面8天一直在D3的东西..都没有时间研究html5.草草的翻了一下HTML5和CSS3权威指南.对整个页面设计有了一个大概的把握,但是让自己做肯定还会有写问题.暂时ht ...
- iOS动态部署之RSA加密传输Patch补丁
概要:这一篇博客主要说明下iOS客户端动态部署方案中,patch(补丁)是如何比较安全的加载到客户端中. 在整个过程中,需要使用RSA来加密(你可以选择其它的非对称加密算法),MD5来做校验(同样,你 ...
- Dom元素的操作
getElementById(): 获取有指定惟一ID属性值文档中的元素 getElementsByName(name): 返回的是数组 getElementsByTagName(): 返回具有指定标 ...
- Delphi XE7中各种字符串与字符类型的内存结构
1. ShortString 类型 定义:type ShortString = string[255]; 内存结构与大小:ShortString 是每个字符为单字节的字符串.ShortString 的 ...
- php获取用户 地区 、ip地址
header("Content-type: text/html; charset=utf-8"); function getCity($ip = '')//获取地区 { if($i ...
- QSS的应用
1.在同一级别的widget中,如果指定widget有设置样式表,则在qss对该样式表的设置无效,对比验证: (StatusWidget未设置widget样式--运行截图) (StatusWidget ...
- 2016 Google code jam 答案
二,RoundC import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundE ...
- Socket网络编程一
1.Socket参数介绍 A network socket is an endpoint of a connection across a computer network. Today, most ...
- Vuejs学习笔记1
首次写vue可能会出现:[Vue warn]: Cannot find element: #app 这是因为你的js在html页面头部引入的原因,自定义js文件要最后引入,因为要先有元素id,vue才 ...
- [MySQL]索引类型总结和使用技巧以及注意事项
一.普通索引 这是最基本的索引,它没有任何限制.它有以下几种创建方式: 1.创建索引 CREATE INDEX [indexName] ON [mytable] ([column][(length)] ...