LintCode 53---翻转字符串中的单词
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---翻转字符串中的单词的更多相关文章
- [LeetCode] Reverse Words in a String 翻转字符串中的单词
Given an input string, reverse the string word by word. For example, Given s = "the sky is blue ...
- [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& ...
- [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 ...
- [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 ...
- [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 ...
- [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 ...
- LeetCode刷题:Reverse Words in a String(翻转字符串中的单词)
题目 Given an input string, reverse the string word by word. For example, Given s = "the sky is b ...
- [LintCode] Reverse Words in a String 翻转字符串中的单词
Given an input string, reverse the string word by word. For example,Given s = "the sky is blue& ...
- [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 ...
- java翻转字符串中的单词
效果: 输入: "java and python" 输出: "avaj dna nohtyp" 代码: 版本1: 不考虑字符串开头有空格,单词间有多个空格空格的 ...
随机推荐
- Springboot websocket使用
1)基本概念 1.http与websocket http超文本传输协议,大家都非常熟悉,http有1.0.1.1. 2.0几个版本,从http1.1起,默认都开启了Keep-Alive,保持连接持续性 ...
- 【Azure】用“Azure Storage Exlporer”进行磁盘拷贝
zure Storage Explorer工具的下载 Azure 存储客户端工具 https://docs.azure.cn/zh-cn/storage/storage-explorers Azure ...
- 调用远程linux服务器shell脚本
package com.haiyisoft.hyoaPc.ui; import java.io.BufferedReader;import java.io.IOException;import jav ...
- 卸载阿里云盾(安骑士)监控&屏蔽云盾IP
卸载阿里云盾监控 wget http://update.aegis.aliyun.com/download/uninstall.sh chmod +x uninstall.sh ./uninstall ...
- 使用Aria2+Aria2Ng+OneIndex+OneDrive建立不限流量/离线BT下载/在线观看网盘/在线存储分享平台
获取OneDrive 自行搜索或者宝购买 安装 1.安装宝塔 #Centos系统 yum install -y wget && wget -O install.sh http://do ...
- Get web site source code
public String getPageSource() { StringBuffer sb = new StringBuffer(); try { // 构建一URL对象 URL url = ne ...
- java tfserving grpc 通信调用代码解析 【重点参考】
https://blog.csdn.net/shin627077/article/details/78592729/ [重点参考]
- 编写javad代码实现使用Scanner从键盘读取一行输入,去掉其中重复字符, 打印出不同的那些字符
package com.loaderman.test; import java.util.HashSet; import java.util.Scanner; public class Test2 { ...
- pandas之数据处理操作
1.pandas对缺失数据的处理 我们的数据缺失通常有两种情况: 1.一种就是空,None等,在pandas是NaN(和np.nan一样) 解决方法: 判断数据是否为NaN:pd.isnull(df) ...
- java高级之Io流
1.1,什么是io流? 流是一组有顺序的,有起点和终点的字节集合,是对数据传输的总称或抽象.即数据在两设备间的传输称为流,流的本质是数据传输,根据数据传输特性将流抽象为各种类,方便更直观的进行数据操作 ...