LeetCode 151 题
来源:互联网 发布:北京飞秋网络 编辑:程序博客网 时间:2024/05/19 21:17
这道题的最主要是要搞清楚空串 Sting s = "";
切割字符串的时候,当有2个空格的时候会切出来一个空串。这样字符串里有很多空串,去掉这些空串,之后的事情就是从后往前遍历字符串数组了
public String reverseWords(String s) {String[] group = s.split(" ");StringBuilder sb = new StringBuilder(group.length);for (int i = group.length - 1; i >= 0; i--) {if (!group[i].equals("") && !group[i].equals(" "))sb.append(group[i]).append(" ");}return sb.toString().trim();}
0 0
- LeetCode 151 题
- leetcode题
- LeetCode 151道题分类+详细解答
- 【LeetCode】LeetCode第一阶段50题小结
- 开始刷刷Leetcode—leetcode第二题
- LeetCode 1.Two Sum ------------LeetCode 第一题
- leetcode 151 Two Sum
- LeetCode 151 Two Sum
- leetcode #151 in cpp
- Leetcode 151(Java)
- LeetCode 高频题
- leetcode 刷题指南
- Leetcode中回文题
- Leetcode中括号题
- leetcode第一题
- leetcode题--Java实现
- 【leetcode】第二题
- 【LeetCode】 刷题计划
- 系统构建初级阶段所要考虑的几点
- HDU 1024 MAX SUM PLUS PLUS
- 恍然大悟!顺其自然就是最高的智慧
- java线程安全总结
- Scala进阶源码实战之五——List、Queue、Stack、Set、Map
- LeetCode 151 题
- [C++] short强转unsigned int引发的问题
- 静态路由
- JQuery Ajax 详解
- 使用virtualenv在ubuntu上搭建python 3开发环境
- TopCoder SRM 688
- 如何及时汇报反馈工作
- google breakpad
- MyBatis中SQL映射的XML文件