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的更多相关文章

  1. [LeetCode] 344 Reverse String && 541 Reverse String II

    原题地址: 344 Reverse String: https://leetcode.com/problems/reverse-string/description/ 541 Reverse Stri ...

  2. Leetcode#344. Reverse String(反转字符串)

    题目描述 编写一个函数,其作用是将输入的字符串反转过来. 示例 1: 输入: "hello" 输出: "olleh" 示例 2: 输入: "A man ...

  3. leetcode 344. Reverse String 、541. Reverse String II 、796. Rotate String

    344. Reverse String 最基础的旋转字符串 class Solution { public: void reverseString(vector<char>& s) ...

  4. LeetCode 344. Reverse String(反转字符串)

    题目描述 LeetCode 344. 反转字符串 请编写一个函数,其功能是将输入的字符串反转过来. 示例 输入: s = "hello" 返回: "olleh" ...

  5. [LeetCode] 344. Reverse String 翻转字符串

    Write a function that reverses a string. The input string is given as an array of characters char[]. ...

  6. Leetcode 344 Reverse String 字符串处理

    题意:反转字符串,用好库函数. class Solution { public: string reverseString(string s) { reverse(s.begin(),s.end()) ...

  7. Python [Leetcode 344]Reverse String

    题目描述: Write a function that takes a string as input and returns the string reversed. Example:Given s ...

  8. (字符串 数组 递归 双指针) leetcode 344. Reverse String

    Write a function that reverses a string. The input string is given as an array of characters char[]. ...

  9. 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) { ...

随机推荐

  1. Ubuntu14.04 lamp环境 php mongodb扩展安装

    安装pecl支持: sudo apt-get install php5-dev php5-cli php-pear 安装mongo驱动 sudo pecl install mongo 修改php.in ...

  2. Linux 下安装JRuby

    安装ruby cd git clone https://github.com/rbenv/rbenv.git ~/.rbenv echo 'export PATH="$HOME/.rbenv ...

  3. Redis 缓存过期(maxmemory) 配置/算法 详解

    LRU(Least Recently Used) 最近最少使用算法是众多置换算法中的一种. Redis中有一个 maxmemory 概念,主要是为了将使用的内存限定在一个固定的大小.Redis 用到的 ...

  4. expect实现自动登录

    自动登录主机(ssh) 建脚本item2login.sh,包含如下内容 #!/usr/bin/expect set timeout 30 spawn ssh -p [lindex $argv 0] [ ...

  5. clearfix的应用

    之前遇到一个问题,引用Bootstrap框架时 一行显示四个模块,小屏幕时显示两个模块 当内容一样时,大小屏幕时一样的,但是当其中一个和另一个内容不同时,展示效果就会有错乱 <div class ...

  6. sss

    function handleTouchEvent(event) {    if (event.touches.length == 1) {        var output = document. ...

  7. IE7 自动为文件路径添加域名

    对于图片等文件的路径,一般在同一个域名下的文件都会使用相对路径,但如果使用JS获取文件的路径浏览器获取到的路径都是相对路径,但IE7会自动为路径添加域名变成绝对路径... IE7下图片路径,在文件相对 ...

  8. phpstudy 80端口被占用,修改端口

    搭建mantis,总会出现80端口被占用的情况.看到别的步骤是:1.cmd 运行netstat -ano查看80端口被什么占用,然后在任务管理器找到对应的结束进程.通常情况下是被System占用,右击 ...

  9. Selenium使用

    定位 1.普通 by id, name,class_name,link_text 2.加强 xpath css

  10. ReWriteDateControll

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...