LeetCode 557 Reverse Words in a String III(反转字符串中的单词3)
来源:互联网 发布:sql中like用法 编辑:程序博客网 时间:2024/05/16 13:42
翻译
原文
Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
Example 1:
Input: “Let’s take LeetCode contest”
Output: “s’teL ekat edoCteeL tsetnoc”
Note: In the string, each word is separated by single space and there will not be any extra space in the string.
代码
public String reverseWords(String s) { String[] strings = s.split(" "); StringBuilder stringBuilder = new StringBuilder(); StringBuffer stringBuffer; for (int i = 0; i < strings.length; i++) { stringBuffer = new StringBuffer(strings[i]); stringBuilder.append(stringBuffer.reverse().toString() + " "); } return stringBuilder.toString().substring(0, stringBuilder.length() - 1); }
1 0
- LeetCode 557 Reverse Words in a String III(反转字符串中的单词3)
- leetcode Reverse Words in a String III 反转字符串中的单词
- Leetcod:557.Reverse Words in a String III 反转字符串中的每个单词。
- LeetCode 151. Reverse Words in a String(反转单词)
- 【LeetCode-面试算法经典-Java实现】【151-Reverse Words in a String(反转字符串中的单词)】
- [LeetCode]557. Reverse Words in a String III(反转字符串 III)
- 字符串-leetcode 557 Reverse Words in a String III
- [LeetCode]Reverse Words in a String-反转单词
- [Leetcode] reverse words in a string 反转单词
- Reverse Words in a String 字符串中单词反转
- LeetCode 557:Reverse Words in a String III (c++)
- LeetCode | Reverse Words in a String(字符串中的单词序反转)
- LeetCode刷题:Reverse Words in a String(翻转字符串中的单词)
- Reverse Words in a String III 翻转字符串中的单词之三
- LeetCode 557 Reverse Words in a String III(逆转字符串)
- LeetCode Reverse Words in a String(反转字符串)
- LeetCode Reverse Words in a String(反转字符串)
- 字符串反转 reverse-words-in-a-string @LeetCode
- 基于tensorflow的MNIST数字识别
- openCV利用航拍相机从底部向上扫描物体拼接全景图
- 目前的感悟
- 平衡二叉树【AVL树】- 通过实例理解概念
- 剑指offer-44.翻转单词顺序列
- LeetCode 557 Reverse Words in a String III(反转字符串中的单词3)
- 动态规划,背包问题变型
- 可逆素数
- (不ROOT/不安装软件/安全)--Android/安卓手机手动冻结/禁用系统应用方法
- PHP 中使用explode()函数切割字符串为数组
- MySQL Order By实现原理分析和Filesort优化
- 各种面试题-虐虐虐
- [cv] filters as templates-normxcorr2(template,img)
- 383. Ransom Note