1、题目:

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

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

2、代码实现:

代码实现1:
    public static String reverseString(String s) {if (s == null) {return null;}if (s.length() == 0) {return "";}int length = s.length();char[] chars = s.toCharArray();String result = "";for (int i = chars.length - 1; i >=0; --i) {result += chars[i];}return result;}
代码实现2:
    public String reverseString(String s) {return new StringBuffer(s).reverse().toString();}

LeetCode之Reverse String相关推荐

  1. LeetCode之Reverse String II

    1.题目 Given a string and an integer k, you need to reverse the first k characters for every 2k charac ...

  2. LeetCode 541. Reverse String II

    题目: Given a string and an integer k, you need to reverse the first k characters for every 2k charact ...

  3. LeetCode 344.Reverse String

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

  4. LeetCode: 344. Reverse String

    051102 题目 Write a function that reverses a string. The input string is given as an array of characte ...

  5. LeetCode 344. Reverse String

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

  6. leetcode 151 Reverse Words in a String (python)

    leetcode 151   Reverse Words in a String 题目描述: Given an input string, reverse the string word by wor ...

  7. leetcode 557. Reverse Words in a String III 、151. Reverse Words in a String

    557. Reverse Words in a String III 最简单的把空白之间的词反转 class Solution { public:string reverseWords(string ...

  8. 【跟Leon一起刷LeetCode】344. Reverse String

    Reverse String Description: Write a function that takes a string as input and returns the string rev ...

  9. LeetCode之Reverse Integer

    1.题目 Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 cli ...

最新文章

  1. shutil模块,为什么说它是os模块的兄弟模块?
  2. 对称加密之分组加密【四】
  3. 最新综述!深度神经网络视觉识别!共计329篇文献!西安交大、清华等合作出品!...
  4. linux脚本定时运行脚本,linux定时运行命令脚本——crontab
  5. mysql测试权限_MySQL运行中被改权限测试
  6. 精选|2018年6月R新包推荐
  7. python pickle反序列化漏洞_渗透测试 - 黑客技术 | 【技术分享】记CTF比赛中发现的Python反序列化漏洞_吾爱漏洞...
  8. 【路径规划】基于matlab遗传算法求解同时取送货车辆路径问题【含Matlab源码 1072期】
  9. 关于计算机算法学习路线(持续更新)
  10. 基于GraphQL的数据网关实现
  11. 计算几何【套模板,推荐模板】 Separating Pebbles UVALive - 7461
  12. 软件架构风格 - 虚拟机风格
  13. 数字电路基础:系统设计优化
  14. mc服务器资源包在什么文件夹,教程/制作资源包 _ 《我的世界》中文Minecraft Wiki:最详细的官方我的世界百科...
  15. 如何通过 onstat 命令监控GBase8s数据库
  16. Mac Mini - 一个深坑
  17. AAAI 2022 | MAVEx—基于知识的视觉问答方法
  18. 理解-1NF,2NF,3NF
  19. amcrest prostream 1080p网络摄像头评论
  20. 计算机网络国际标准界最,计算机网络标准综述.pdf

热门文章

  1. 张善友: .NET社区运营 | 2021 中国开发者生态峰会
  2. [C#.NET 拾遗补漏]14:使用结构体实现共用体
  3. 【招聘(西安)】深圳市中兴云服务有限公司.NET工程师
  4. Azure 内容审查器之文本审查
  5. Azure DevOps+Docker+Asp.NET Core 实现CI/CD(三.实现CD持续部署管道)
  6. 微软 Visual Studio 2019 16.5 发布:.NET 移动开发、生产力
  7. ASP.NET Core on K8S深入学习(10)K8S包管理器Helm-Part 1
  8. Excel催化剂插件功能修复与更新汇总篇之十
  9. IT从业者的迷思与求解之道——座谈会实录摘选
  10. CAP带你轻松玩转ASP.NETCore消息队列