public static String oneScan(String s){
    if(s==null) return null;
    StringBuilder result = new StringBuilder();
    int end = s.length();
    for(int i=s.length()-1;i>=0;i--){
      if(s.charAt(i)==' '){
        end = i;
        continue;
      }
      if(i==0||s.charAt(i-1)==' '){
        if(result.length()!=0){
          result.append(' ');
        }
        result.append(s.substring(i, end));
      }
    }
    return result.toString();
  }