Five Star Sellers
Problem A seller's rating is the average over products of (five-star reviews / total reviews). Given each product's [fiveStar, total] and a target percentage, return the minimum number of additional five-star reviews (each added to any product, incrementing both its counts) needed to reach the target average.
Input / Output
- Input: productRatings as pairs [fiveStar, total], int ratingsThreshold (percentage).
- Output: the minimum number of five-star reviews to add.
Constraints
- Up to 200 products, threshold < 100.
- A five-star review adds 1 to both the product's fiveStar and total counts.
Example
- products = [[4,4],[1,2],[3,6]], threshold = 77 → 3 (adding to the products with the largest marginal gain reaches an average ≥ 0.77).
asked …