give hint for dividing array greedy approach
Dividing array greedy
Hello @shrutikatyal Here you need to find minimum and maximum possible value for sum of abs(a[i]-b[i]) for i from 0 to n-1. Approach:
- for maximum, pair largest element with smallest, 2nd largest with second smallest and so on.
- for mimimum, pair smallest element with 2nd smallest or arr[i] with arr[i+1] for every i=0,2,4,6…
try implementing this
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.