r/learnquant • • 4d ago

interview prep Quant Interview Question

Post image
57 Upvotes

20 comments sorted by

View all comments

1

u/Ximaths 4d ago

338151.Permutation: 1, 3, 5,…, 99, 100, 98,…., 4, 2.

1

u/Erwins-Cat 2d ago

had to scroll far to far to find this solution...

for all others, why this is a better way than just sorting 1, ... , 100: two elements are multiplied only once: a_1 and a_100. All other elements are used twice in multiplication. Puttint 100 to a_1 or a_100 means you are not using the 100 with full potential for multiplication, you wasted it once.  The upper algo makes sure that all larger numbers used twice and only the lowest numbers, 1 and 2, are used once.