<awangdev>139. Word Break_2.java
private boolean dfs(Set<String> dict, Set<String> set, String s) {

        if (dict.contains(s)) return true;
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            sb.append(c);
            if (dict.contains(sb.toString())) {
                String sub = s.substring(i + 1);
                if (set.contains(sub)) continue;
                if (dfs(dict, set, sub)) return true;
                set.add(sub);
            }
        }
        return false;
    }
private boolean sample_funcname ( Set < String > dict , Set < String > set , String s ) {
  if ( dict . contains ( s ) ) return true ;
  StringBuffer sb = new StringBuffer ( ) ;
  for ( int i = 0 ;
  i < s . length ( ) ;
  i ++ ) {
    char c = s . charAt ( i ) ;
    sb . append ( c ) ;
    if ( dict . contains ( sb . toString ( ) ) ) {
      String sub = s . substring ( i + 1 ) ;
      if ( set . contains ( sub ) ) continue ;
      if ( dfs ( dict , set , sub ) ) return true ;
      set . add ( sub ) ;
    }
  }
  return false ;
}
