mycode

class Solution(object):
def reverseString(self, s):
"""
:type s: List[str]
:rtype: None Do not return anything, modify s in-place instead.
"""
s = s.reverse()

参考:更快

class Solution(object):
def reverseString(self, s):
"""
:type s: List[str]
:rtype: None Do not return anything, modify s in-place instead.
"""
temp = ""
for i in range(len(s) / 2):
temp = s[i]
s[i] = s[len(s)-1-i]
s[len(s)-1-i] = temp

leetcode-easy-string-344 Reverse String的更多相关文章

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

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

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

  3. 344. Reverse String【easy】

    344. Reverse String[easy] Write a function that takes a string as input and returns the string rever ...

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

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

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

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

  6. 【leetcode】344. Reverse String

    problem 344. Reverse String solution: class Solution { public: void reverseString(vector<char> ...

  7. 344. Reverse String(C++)

    344. Reverse String Write a function that takes a string as input and returns the string reversed. E ...

  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 344 Reverse String 字符串处理

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

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

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

随机推荐

  1. a标签的download属性

    a标签加上downlaod属性后,就可完成对href属性链接文件的下载,但仅仅是限于同源文件,如果是非同源,download属性会失效. 无download属性的时候,a标签的默认行为是链接跳转进行预 ...

  2. 1、linux基础优化

    1.添加一个用户 [root@oldboy ~]# useradd oldboy [root@oldboy ~]# id oldboy uid=500(oldboy) gid=500 (oldboy) ...

  3. PIL:处理图像的好模块

    介绍 PIL是一个专门用来处理图像的模块,可以对图象进行各种各样的变换 打开一张图片 from PIL import Image # 调用Image下的open方法,即可打开一张图片 # 得到的im便 ...

  4. uestc summer training #9 牛客第三场 BFS计数

    G.coloring tree BFS计数 题目:给你n(<=5000)个节点的一颗树 你有K(<=5000)种颜色 你可以给每一个节点染一种颜色 总共有Kn种染色方法 在一种染色方法中 ...

  5. 第二天·初识HTML

    一·什么是HTML HTML(HyperText Markup Language)是超文本标记语言,"超文本"的意思就是指页面内可以包含图片.链接,甚至音乐.程序等非文字元素.不仅 ...

  6. Hibernate 缓存机制详细分析

    在本篇随笔里将会分析一下hibernate的缓存机制,包括一级缓存(session级别).二级缓存(sessionFactory级别)以及查询缓存,当然还要讨论下我们的N+1的问题. 随笔虽长,但我相 ...

  7. eclipse svn同步过滤掉某些不需要同步的文件

    注:这里说的svn是eclipse里svn插件 默认情况下,我们在点击svn同步时,总是会把一些不需要的目录和文件也给同步了,这样我觉得很晃眼睛,所以在这里说下怎么去去掉不想同步的文件 1.默认同步下 ...

  8. 对vue-router的研究--------------引用

    pushState/replaceState/popstate 解析 HTML5提供了对history栈中内容的操作.通过history.pushState/replaceState实现添加地址到hi ...

  9. 项目的Servlet类找不到

    先右击项目,

  10. Resttemplate请求失败如何获取返回的json

    参考:https://blog.csdn.net/u011974797/article/details/82424004 https://www.cnblogs.com/liumz0323/p/106 ...