@28nehasinha-gmail-com Go through the code, you will find the max number and min number of same array will never be calculated the difference. We initialized the min and max from the first interval. What happened next? We calculated the difference between current interval min and previous intervals max, And the difference between current interval max and previous intervals min. Then we update the min and max. So each operation we will only pick min or max number of current interval. So there are no chance to let min and max of same interval to calculate the difference. lol poor English expression. Hope can help you a little bit.
Maximum Distance in Arrays