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. spark streaming 6: BlockGenerator、RateLimiter

    BlockGenerator和RateLimiter其实很简单,但是它包含了几个很重要的属性配置的处理,所以记录一下. ))) , SECONDS) From WizNote

  2. ORA-01148:cannot refresh file size for datafile ***

    ORA-01148: cannot refresh file size for datafile * Table of Contents 1. 版本信息 2. 错误信息 3. 收集错误信息 4. 故障 ...

  3. nginx的root 指令

    好长时间都没搞清nginx的root路径: location /img/ { alias /var/www/image/; } #若按照上述配置的话,则访问/img/目录里面的文件时,ningx会自动 ...

  4. Java之HSF搭建demo

    1.去阿里云官网下载Demo edas-app-demo.zip 2.下载Ali-Tomcat和Pandora,注意红色下面字体 a)下载 Ali-Tomcat,保存后解压至相应的目录(如:d:\wo ...

  5. C基础知识(11):错误处理

    C语言不提供对错误处理的直接支持,但是作为一种系统编程语言,它以返回值的形式允许您访问底层数据.在发生错误时,大多数的C或UNIX函数调用返回1或NULL,同时会设置一个错误代码errno,该错误代码 ...

  6. java:svn

    1.配置: 在windows系统中,操作svn的工具最长用的是小乌龟svn 服务器端(项目所在的服务器上):在java开发中几乎所有的服务器为Linux系统 需要在Linux系统中进行安装 1.修改h ...

  7. windows客户端如果通过cmd窗口连接到远程linux服务器,可以使用telnet;

     linux系统打开telnet端口的方法 2016-03-11 16:02:25 标签:linux telnet 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明. ...

  8. Tor路径选择说明

    Tor Path Specification Roger Dingledine Nick Mathewson Note: This is an attempt to specify Tor as cu ...

  9. input.validity

    HTML5为表单提供了自带的输入规则提示 但是实际开发中,我们往往需要自定义提示消息和规则,例如限定了最大值但不要求超出时提示错误信息,这时便用到了H5提供的表单新的JS属性--validity,它是 ...

  10. Django与Cookie

    Cookie Cookie的由来 ​ 大家都知道HTTP协议是无状态的.无状态的意思是每次请求都是独立的,它的执行情况和结果与前面的请求和之后的请求都无直接关系,它不会受前面的请求响应情况直接影响,也 ...