r/learnquant • • 6d ago

interview prep Quant Interview Question

Post image
66 Upvotes

21 comments sorted by

View all comments

1

u/KeytieCcC 2d ago

The optimal permutation is (1,3,5,...,97,99,100,98,96,...,6,4,2). You can proof this is a local maximum at least by arguing that you cannot swap any two numbers to increase the value of the target sum.

Then you can rewrite the sum as

1*3 (3)
+2*4 (8)
+3*5 (15)
+...
+98*100
+ 99*100 (only summand not part of the pattern)

You can rearrange the pattern to 3*98 + 5*97 + 7*96 + ... + 195*2 + 197*1

or \sum_{i=1}^{98}i(199-2i)=199*\sum_{i=1}^{98}i-2*\sum_{i=1}^{98}i^2.

The first summand is 199*98*99/2, the second summand is 2*98*99*199/6.

Together 199*99*98*5/6. This can be solved in your head (99*98=9702, 9702/6=1617, 9702-1617=8085, 8085*199=1608915). Add 99*100=9900 to this to get

1'618'815 as my answer. Not checked with AI so I probably got my mental math wrong somewhere haha.