<gouthampradhan>dynamic_programming_WordBreak_1.java
private boolean dp(int i, String s, Map<Integer, Boolean> dic, Set<String> dictionary) {
    if (i == s.length()) return true;
    else if (dic.containsKey(i)) return dic.get(i);
    else {
      for (int j = i, l = s.length(); j < l; j++) {
        String subStr = s.substring(i, j + 1);
        if (dictionary.contains(subStr)) {
          if (dp(j + 1, s, dic, dictionary)) {
            dic.put(i, true);
            break;
          }
        }
      }
    }
    if (!dic.containsKey(i)) dic.put(i, false);
    return dic.get(i);
  }
private boolean sample_funcname ( int i , String s , Map < Integer , Boolean > dic , Set < String > dictionary ) {
  if ( i == s . length ( ) ) return true ;
  else if ( dic . containsKey ( i ) ) return dic . get ( i ) ;
  else {
    for ( int j = i , l = s . length ( ) ;
    j < l ;
    j ++ ) {
      String subStr = s . substring ( i , j + 1 ) ;
      if ( dictionary . contains ( subStr ) ) {
        if ( dp ( j + 1 , s , dic , dictionary ) ) {
          dic . put ( i , true ) ;
          break ;
        }
      }
    }
  }
  if ( ! dic . containsKey ( i ) ) dic . put ( i , false ) ;
  return dic . get ( i ) ;
}
