It is showing wrong ans in some test cases
but i have taken help from gfg , there they did the same thing
Do similar thing for arr[i] dimensions as you do for arr[i+1] and arr[i+2] (that length is minimum and breadth is maximum for remaining two sides)
Oh yes , i got ac finally , Thanks sir