public class Solution {
/*
* @param s: A string
* @return: A string
*/
public static String reverseWords(String s) {
if(s==null || s.length() == 0) return "";
String[] array = s.split(" ");
StringBuilder sb = new StringBuilder();
for (int i = array.length - 1; i>=0; --i) {
if(!array[i].equals("")){
sb.append(array[i]).append(" ");
}
}
return sb.toString();
}
}

LintCode 53---翻转字符串中的单词的更多相关文章

  1. [LeetCode] Reverse Words in a String 翻转字符串中的单词

    Given an input string, reverse the string word by word. For example, Given s = "the sky is blue ...

  2. [LeetCode] 151. Reverse Words in a String 翻转字符串中的单词

    Given an input string, reverse the string word by word. For example,Given s = "the sky is blue& ...

  3. [LeetCode] 186. Reverse Words in a String II 翻转字符串中的单词 II

    Given an input string, reverse the string word by word. A word is defined as a sequence of non-space ...

  4. [LeetCode] 557. Reverse Words in a String III 翻转字符串中的单词 III

    Given a string, you need to reverse the order of characters in each word within a sentence while sti ...

  5. [LeetCode] Reverse Words in a String II 翻转字符串中的单词之二

    Given an input string, reverse the string word by word. A word is defined as a sequence of non-space ...

  6. [LeetCode] Reverse Words in a String III 翻转字符串中的单词之三

    Given a string, you need to reverse the order of characters in each word within a sentence while sti ...

  7. LeetCode刷题:Reverse Words in a String(翻转字符串中的单词)

    题目 Given an input string, reverse the string word by word. For example, Given s = "the sky is b ...

  8. [LintCode] Reverse Words in a String 翻转字符串中的单词

    Given an input string, reverse the string word by word. For example,Given s = "the sky is blue& ...

  9. [Swift]LeetCode186. 翻转字符串中的单词 II $ Reverse Words in a String II

    Given an input string, reverse the string word by word. A word is defined as a sequence of non-space ...

  10. java翻转字符串中的单词

    效果: 输入: "java and python" 输出: "avaj dna nohtyp" 代码: 版本1: 不考虑字符串开头有空格,单词间有多个空格空格的 ...

随机推荐

  1. DP&图论 DAY 6 下午 考试

    DP&图论  DAY 6  下午  考试 样例输入 样例输出 题解 >50 pt      dij 跑暴力 (Floyd太慢了QWQ    O(n^3)) 枚举每个点作为起点,dijks ...

  2. Android版本之间的区别

    不同版本SDK适配要点 1,指定minSDKVersion与targetSDKVersion 2,运行时获取版本号 3,使用系统内置的主题,会随着版本的更换而自动适配 4,用android提供的注解 ...

  3. Springboot获取resource的路径

    1.获取resource目录下的template路径 String path = Thread.currentThread().getContextClassLoader().getResource( ...

  4. 安卓之Android.mk编写

    题记:编译环境可以参考https://www.cnblogs.com/ywjfx/p/9960817.html 不管是写C还是java,我想所有的程序员都经历过HelloWorld程序的编写,现在让我 ...

  5. JavaScript 格式化数字成金额格式

    在看公司一个项目的JavaScript代码时,发现一段JavaScript代码,是把数字格式化成金额格式 比如: 12345.678 格式化成  12,345.68 看完代码后,google了一下,发 ...

  6. Python安装远程调试Android需要的扩展脚本

    http://android-scripting.googlecode.com/hg/python/ase/android.py 拷贝到/Python27/Lib/site-packages这个目录下 ...

  7. vscode开发ExtJs安装插件以及破解方法

    https://blog.csdn.net/lovelyelfpop/article/details/69568995 1.官网下载vscode 插件. https://www.sencha.com/ ...

  8. 分享一款架子鼓游戏【drum】

    视频演示: 电脑版和安卓版都有,没有ios版. 适合想练架子鼓,但是还没买架子鼓的朋友.可以先当做游戏来练练节奏感...下载如下: 电脑版下载>> 手机安卓版下载>>

  9. caoz的梦呓:所谓打破信息不对称,其实是一种幻觉

    猫宁!!! 参考链接:https://mp.weixin.qq.com/s/UzSyrhe0Vck7ItN-XU6JEg 很多创业者说,要建立怎样一个平台,要打破信息不对称,大部分时候,我都会泼冷水, ...

  10. Django的一些注意事项

    不要使用 Python 或 Django 的组件名命名项目.具体而言,不要使用“django”(与 Django 冲 突)或“test”(与 Python 内置的一个包冲突)这样的名称. 在中文版中, ...