【Question】

  • Write a function that takes a string as input and returns the string reversed.

  • Example:

Given s = "hello", return "olleh".


【My Solution】

  • Slice 切片
class Solution(object):
def reverseString(self, s):
"""
:type s: str
:rtype: str
"""
s = s[::-1]
return s
  • 分析

    利用python的切片特性,反向切片即可

【LeetCode】#344 Reverse String的更多相关文章

  1. 【leetcode】344. Reverse String

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

  2. 【LeetCode】344. Reverse String 解题报告(Java & Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 新构建字符串 原地翻转 日期 题目地址:https://lee ...

  3. 【一天一道LeetCode】#344. Reverse String

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Write a ...

  4. 【LeetCode】541. Reverse String II 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 Java解法 Python解法 日期 题目地址:ht ...

  5. 【leetcode】557. Reverse Words in a String III

    Algorithm [leetcode]557. Reverse Words in a String III https://leetcode.com/problems/reverse-words-i ...

  6. 【LeetCode】481. Magical String 解题报告(Python)

    [LeetCode]481. Magical String 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http:/ ...

  7. 【LeetCode】880. Decoded String at Index 解题报告(Python)

    [LeetCode]880. Decoded String at Index 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博 ...

  8. 【LeetCode】151. Reverse Words in a String

    Difficulty: Medium  More:[目录]LeetCode Java实现 Description Given an input string, reverse the string w ...

  9. 【LeetCode】557. Reverse Words in a String III 解题报告(Java & Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 Java解法 Python解法 日期 题目地址:ht ...

随机推荐

  1. python之信用卡ATM(第五天)

    本节作业 作业需求: 模拟实现一个ATM + 购物商城程序 额度 15000或自定义 实现购物商城,买东西加入 购物车,调用信用卡接口结账 可以提现,手续费5% 每月22号出账单,每月10号为还款日, ...

  2. python之RabbitMQ

    一.安装RabbitMQ 1. 安装erlang 1 2 3 4 tar xf otp_src_18.3.tar.gz cd otp_src_18.3 ./configure --prefix=/ma ...

  3. easyUI + swfupload 多附件上传功能

    public void UPLOADFILED() { Date dt = new Date(System.currentTimeMillis()); SimpleDateFormat sdf = n ...

  4. MFC动态创建菜单

    http://blog.csdn.net/csdnzhwk/article/details/47395639

  5. 构建ceph deb 安装包

    前言:本文基于ubuntu 14.04.5 LTS 和ceph v0.94.3 之上做的实验 一.编译ceph包1.1.克隆ceph代码,切换分支 git clone --recursive http ...

  6. itput

    这个网站也非常好,有很多金融it知识免费下载,下载验证码t7QA,名字新共产主义

  7. mysql 唯一约束

    ALTER TABLE user ADD UNIQUE (username,userid) 对表user增加username和userid的唯一约束 ALTER TABLE tablename  AD ...

  8. [转]UE4 Blueprint编译过程

    Blueprint 编译概述   一.术语 Blueprint,像C++语言一下的,在游戏中使用前需要编译.当你在BP编辑器中,点击编译按钮时候,BP资源开始把属性和图例过程转换为一个类对象处理. 1 ...

  9. 通过js引用外部脚本(嘿嘿,方便直接在浏览器上调试抓取代码)

    最近折腾爬虫,后端使用jQuery进行数据采集,一般都是先从浏览器中将采集代码调试好后直接放到后端跑了. 有些网址没有引用jQuery,那调试起来就不方便了,可以用以下代码动态添加script标签,将 ...

  10. 框架整合----------Hibernate、spring整合

    说到整合框架,其实也就是环境的搭建了,首先我们要导包,这里连接数据库我们用到了spring容器,我们用连接池来进行数据库的连接,我们需要导入c3p0和jdbc的jar包,其余的就是spring和Hib ...