[DAY1] New Year Chaos
1 min readOct 14, 2019
https://www.hackerrank.com/challeng…/new-year-chaos/problem…
Solution 1: Use Bubble Sort algorithm, but the time complexity would be O(N²). Since some test cases are time limited, we won’t pass those test cases even if we get the right solutions.
Solution 2: Only considering for each person in the line, how many people bribed them. And since each person could bribe at most two people in order to move forward. So the person might have bribed me would range from my original position minus one to the position standing now minus 1. People with greater original position number would have bribed me.