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.
- Prepare
- Algorithms
- Greedy
- Luck Balance
- Discussions
Luck Balance
Luck Balance
Sort by
recency
|
897 Discussions
|
Please Login in order to post a comment
def luckBalance(k, contests): # Write your code here
I solve this with Java language. Normally, i saw everyone solve this problem with the idea to calculate the total value and at the end minus to the minimum possible value. This method can be done with O(n) to calculate sum, O(n* log(m)) to sort (m <= n) and then traverse it O(m) to minus as the followed idea. Mine use heap as a quicker way (i believe) to solve this problem with only O(n* log(k)) time complexity and O(k) space complexity.
javascript
swift simple solution