We have two integer arrays A and B of size n. Sequence A is increasing and B is decreasing. The union of elements from A & B forms the set of numbers from 1 to 2n. Prove that, for any two such sequences we have \sum_{i=1}^n | A[i] - B[i] | = n^2.
#exportoberScreenshot

# 1445395530721505280

Screenshot

URLs

Follower Count

4399

TweetURL

https://twitter.com/algopuzzles/status/1445395530721505280

User

algopuzzles

Created At

2021-10-05T14:28:43.000Z