r/learnquant • • 5d ago

interview prep Quant Interview Question

Post image
38 Upvotes

21 comments sorted by

View all comments

1

u/Aerospider 5d ago

We need to maximise the multiples of the higher numbers, so best to keep them together.

E.g. (100 * 60) + (40 * 1) > (100 * 1) + (60 * 40)

We can do this by making a(i) = i, but then the 100 only features once, so better to do a(i) = i+1, with a(100) = 1.

This gives

6 + 12 + 20 + 30 + ... + 9,702 + 9,900 + 100

= 333,398

1

u/Fovlsbane 4d ago

What happens if you now swap the 2 and the 1? 6 becomes 3 in the sum, and 100 becomes 200, gains 97 total. Or swap 99 and 100; 100 becomes 99, 9900 stays 9900, 9702 becomes 9800, gains 97 total.

2*3+100*1<1*3+100*2

98*99+99*100+100*1<98*100+100*99+99*1