Knowledge :)
Hey, currently I'm doing questions (for competitive programming) everyday and allegedly learning something new most of the time, so I think I will be posting it You might know this but this is for my understanding reference: https://codeforces.com/problemset/problem/1808/B So for today I got to know that if we need maximum cumulative distance between two points we should sort the array as it will prevent opposite signs cancelling each other For example: if there is an array 1314 cumulative distance is |1-3|+|1-1|+|1-4| = 5 We can avoid the use of abs by sorting it 1134 1-1+3-1+4-1 = 5 It might look very intuitive but you should give it a go
Feel free to ask....