[
math
]
BinarySearch 0975 5-Star Review Percentage
Problem statement
https://binarysearch.com/problems/5-Star-Review-Percentage/
Solution
Just use math here.
Complexity
It is O(n)
for time and O(1)
for space.
Code
class Solution:
def solve(self, R, T):
if T == 100: return 0
return max(0, ceil((T*sum(y for _, y in R) - 100*sum(x for x, _ in R))/(100 - T)))