public static String buildString(String str){
  StringBuilder builder=new StringBuilder();
  List<Integer> possibleLocations=possibleLocations(str);
  if (possibleLocations.isEmpty()) {
    return null;
  }
  List<Integer[]> confirmedLocations=confirmedLocations(str,possibleLocations);
  if (confirmedLocations.isEmpty()) {
    return null;
  }
  int lastEnd=0;
  for (  Integer[] pair : confirmedLocations) {
    int start=pair[0];
    int length=pair[1];
    int end=start + length;
    builder.append(str.substring(lastEnd,start));
    builder.append(interpolate(str.substring(start,end)));
    lastEnd=pair[0] + pair[1];
  }
  return builder.toString();
}

public static String buildString ( String str ) { StringBuilder builder = new StringBuilder ( ) ; List < Integer > possibleLocations = possibleLocations ( str ) ; if ( possibleLocations . isEmpty ( ) ) { return null ; } List < Integer [ ] > confirmedLocations = confirmedLocations ( str , possibleLocations ) ; if ( confirmedLocations . isEmpty ( ) ) { return null ; } int lastEnd = 0 ; for ( Integer [ ] pair : confirmedLocations ) { int start = pair [ 0 ] ; int length = pair [ 1 ] ; int end = start + length ; builder . append ( str . substring ( lastEnd , start ) ) ; builder . append ( interpolate ( str . substring ( start , end ) ) ) ; lastEnd = pair [ 0 ] + pair [ 1 ] ; } return builder . toString ( ) ; }
begins building the string from interpolation and normal string contents .
