We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- New Year Chaos
- Discussions
New Year Chaos
New Year Chaos
Sort by
recency
|
291 Discussions
|
Please Login in order to post a comment
Here is my solution in Java. I initially solved it by replacing the elements in list with its correct position and counting the bribes while doing that. That yielded result but few of the test cases failed due to performance. I tried a little in local IDE and took help online to arrive at this solution}
`
It seems as though this problem operates under the assumption that people execute their bribes from the front to the back of their initial position.
Python solution:
This approach is mostly about the fact that we only need to count all people in front of us (who could bribe the current person and not more than two bigger than us) def minimumBribes(q): bribes = 0