1. 程式人生 > >LintCode 53---翻轉字符串中的單詞

LintCode 53---翻轉字符串中的單詞

urn solution span spa col == array rev stat

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---翻轉字符串中的單詞