Performance Analysis
I believe I did pretty good for my first contest. I have recently started working on this platform and have set an ambition to reach Legendary Grandmaster.
Coming to the analysis part.
A. Convergence
The problem was based mostly on logical reasoning and figuring out the pattern. Firstly we had to sort the array then choose a target number (location) where all the friend would meet.
To figure out the location choose a number and figure out how many friends are on the left side of that number and how many are on the right side. Do this and figure out the number with optimal left and right side values. '
That's it..!
B. Cake Leveling
This was a problem based on figuring out the mathematical form and pattern recognition in some sense. we had to find the optimal height of frosting at each index.
To do that first store the current sum of the height of frosting, then figure out the average based on the index (we can think of it as layer of the cake Ex. 1st Layer...) and current sum of the frosting, to figure out the optimal height of frosting.
Next, the minimum of average calculated of current level and average of previous level, to manage the excess frosting problem.
Here is exactly how that math manages the "excess frosting" behavior:
When there is excess frosting early on: The prefix average will naturally be high. Because the excess rolls forward to help fill the later positions, future positions can absorb it, and the leveling height can stay relatively high.
When there is a huge deficit (a low spot) early on: The prefix average will suddenly drop. Because frosting cannot travel backward, a later position with a massive mountain of frosting cannot go back and rescue that early low spot. That early bottleneck permanently caps the maximum possible leveled height for the rest of the cake.



