Function to return the ending index for the largest valid sub - string starting from index i
static int getEndingIndex ( String str , int n , int i ) { i ++ ; while ( i < n ) { char curr = str . charAt ( i ) ; char prev = str . charAt ( i - 1 ) ;