LeetCode之Reverse String
1、题目:
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
2、代码实现:
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;}
public String reverseString(String s) {return new StringBuffer(s).reverse().toString();}
LeetCode之Reverse String相关推荐
- LeetCode之Reverse String II
1.题目 Given a string and an integer k, you need to reverse the first k characters for every 2k charac ...
- LeetCode 541. Reverse String II
题目: Given a string and an integer k, you need to reverse the first k characters for every 2k charact ...
- 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
051102 题目 Write a function that reverses a string. The input string is given as an array of characte ...
- LeetCode 344. Reverse String
题目: Write a function that takes a string as input and returns the string reversed. Example: Given s ...
- 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 ...
- 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 ...
- 【跟Leon一起刷LeetCode】344. Reverse String
Reverse String Description: Write a function that takes a string as input and returns the string rev ...
- LeetCode之Reverse Integer
1.题目 Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 cli ...
最新文章
- shutil模块,为什么说它是os模块的兄弟模块?
- 对称加密之分组加密【四】
- 最新综述!深度神经网络视觉识别!共计329篇文献!西安交大、清华等合作出品!...
- linux脚本定时运行脚本,linux定时运行命令脚本——crontab
- mysql测试权限_MySQL运行中被改权限测试
- 精选|2018年6月R新包推荐
- python pickle反序列化漏洞_渗透测试 - 黑客技术 | 【技术分享】记CTF比赛中发现的Python反序列化漏洞_吾爱漏洞...
- 【路径规划】基于matlab遗传算法求解同时取送货车辆路径问题【含Matlab源码 1072期】
- 关于计算机算法学习路线(持续更新)
- 基于GraphQL的数据网关实现
- 计算几何【套模板,推荐模板】 Separating Pebbles UVALive - 7461
- 软件架构风格 - 虚拟机风格
- 数字电路基础:系统设计优化
- mc服务器资源包在什么文件夹,教程/制作资源包 _ 《我的世界》中文Minecraft Wiki:最详细的官方我的世界百科...
- 如何通过 onstat 命令监控GBase8s数据库
- Mac Mini - 一个深坑
- AAAI 2022 | MAVEx—基于知识的视觉问答方法
- 理解-1NF,2NF,3NF
- amcrest prostream 1080p网络摄像头评论
- 计算机网络国际标准界最,计算机网络标准综述.pdf
热门文章
- 张善友: .NET社区运营 | 2021 中国开发者生态峰会
- [C#.NET 拾遗补漏]14:使用结构体实现共用体
- 【招聘(西安)】深圳市中兴云服务有限公司.NET工程师
- Azure 内容审查器之文本审查
- Azure DevOps+Docker+Asp.NET Core 实现CI/CD(三.实现CD持续部署管道)
- 微软 Visual Studio 2019 16.5 发布:.NET 移动开发、生产力
- ASP.NET Core on K8S深入学习(10)K8S包管理器Helm-Part 1
- Excel催化剂插件功能修复与更新汇总篇之十
- IT从业者的迷思与求解之道——座谈会实录摘选
- CAP带你轻松玩转ASP.NETCore消息队列