Greedy approach proof

Revision en1, by rr459595, 2019-08-06 09:19:10

I solved this problem on hackerrank ( https://www.hackerrank.com/contests/dcl2k15/challenges/mice-v1 ) based on greedy approach. I am not able to understand the proof of the greedy approach.

The proof says max( |a1-b1| , |a2-b2| ) <= max( |a1-b2|, |a2-b1| ) for a1<a2 and b1<b2. Can someone help me in proving the inequality?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English rr459595 2019-08-06 09:19:10 350 Initial revision (published)