Including the greater repeating values so that product can be maximized
product *= pow ( arr [ j ] , s [ arr [ j ] ] - 1 ) ; NEW_LINE k = k - s [ arr [ j ] ] + 1 ; NEW_LINE s [ arr [ j ] ] = 0 ; NEW_LINE if ( k <= ( s [ arr [ j ] ] - 1 ) and ( ( s [ arr [ j ] ] - 1 ) > 0 ) ) : NEW_LINE product *= pow ( arr [ j ] , k ) ; NEW_LINE break ; NEW_LINE j -= 1 NEW_LINE return product ; NEW_LINE