<awangdev>140. Word Break II_2.java
public void helper(List<String> result, List<String> list, boolean[][] isWord, boolean[] isValid, String s, int start) {
        if (!isValid[start]) {
            return;
        }
        if (start >= s.length()) {
            StringBuffer sb = new StringBuffer();
            for (String word : list) {
                sb.append(word + " ");
            }
            result.add(sb.toString().trim());
            return;
        }
        for (int i = start; i < s.length(); i++) {
            if (!isWord[start][i]) {
                continue;
            }
            list.add(s.substring(start, i + 1));
            helper(result, list, isWord, isValid, s, i + 1);
            list.remove(list.size() - 1);
        }
    }
public void sample_funcname ( List < String > result , List < String > list , boolean [ ] [ ] isWord , boolean [ ] isValid , String s , int start ) {
  if ( ! isValid [ start ] ) {
    return ;
  }
  if ( start >= s . length ( ) ) {
    StringBuffer sb = new StringBuffer ( ) ;
    for ( String word : list ) {
      sb . append ( word + " " ) ;
    }
    result . add ( sb . toString ( ) . trim ( ) ) ;
    return ;
  }
  for ( int i = start ;
  i < s . length ( ) ;
  i ++ ) {
    if ( ! isWord [ start ] [ i ] ) {
      continue ;
    }
    list . add ( s . substring ( start , i + 1 ) ) ;
    helper ( result , list , isWord , isValid , s , i + 1 ) ;
    list . remove ( list . size ( ) - 1 ) ;
  }
}
