If str [ i ] is between 0 and 9 and i is the last occurence in str
else if ( ( str [ i ] >= ' 0 ' && str [ i ] <= '9' ) && num [ str [ i ] - 48 ] == i ) { int occ = str [ i ] - 48 ; while ( occ -- > 0 ) { res = res + str [ i ] ; } } else { res = res + str [ i ] ; } }