educative.io

Hope can explain lst[i] += (lst[maxIdx] % maxElem) * maxElem

From question 10, rearrange sorted list in max/min form

https://www.educative.io/courses/data-structures-coding-interviews-python/qVD52x8PKv7

In example of article - [1, 2, 3, 4, 5, 6, 7, 8, 9], it said that 91 is stored at index
0. l guess it using the formula (lst[i] += (lst[maxIdx] % maxElem) * maxElem ).But l failed to get the result 91. Could you show the process that how to get 91?

Thanks

This should be 90 instead of 91. lst[i] += (lst[maxIdx] % maxElem) * maxElem => (9%10)*10 = 90.

Anum Hassan|Developer Advocate
educative.io