max difference solution 2