Binary Search
Demo
Star Sum
Amazon Online Assessment
E-Mart Product Ranking
Amazon Online Assessment
Minimum Total Wattage
Amazon Online Assessment
Best Stock Combos
Amazon Online Assessment Subset
Split String
Amazon Online Assessment Array
Find Pairs
Amazon Online Assessment Array
Merge Adjacent Numbers
Amazon Online Assessment Array
Split Array III
Amazon Online Assessment Array
Minimum Number of Swaps
Amazon Online Assessment Array
Collection of Circles
Google Onsite MST
Search Extensible String
New Google Onsite
Maximum Deviation Among All Substrings
Online Assessment String
Maximum Greyness
New Online Assessment Matrix
Separate Pages
New Online Assessment Bit
Shop for Clothes on a Budget
New Online Assessment
Color Palette
Online Assessment Array
Min Appends to Make Subsequence
Online Assessment String
Min Swaps to Partition
New Online Assessment
Minimum Net Price Change
New Online Assessment Intern Array
Channels Maximum Quality
New Online Assessment
Slice Array
New Online Assessment Array
Stock Fluctuation
New Online Assessment Array
Decoding String
New Online Assessment String
Maximum Precipitation
New Online Assessment
Count Reviews II
New Online Assessment
Count Reviews Combinations
New Online Assessment
LRU Browser History
New Online Assessment
Split Array II
Amazon Google New
Load Cargo
Amazon Google New
Split Array
Amazon Google New
Find Bridges In A Graph
Amazon Google MST New
Closest Pair of Molecules
Google Amazon New
Search Matrix
Facebook New
Max Submatrix Sum
Google Facebook New
Cache Hit Ratio
Google Facebook Amazon New
Find Cut Vertices
Google Amazon New
Two Sum Smaller Than Target
Google Amazon New
Can Make Palindrome
Facebook New
Discount Calculator
Amazon New Online Assessment
Max Sink Area
Amazon New
Measure Island Border
Facebook New
Construct Word Using Dice
Google New
Recursive Islands and Lakes
Google Hard New
Packaging Automation
Amazon New Online Assessment
Secret Fruit List
Amazon Online Assessment New
Find Related Products
Amazon Online Assessment New
Optimize Memory Usage
Online Assessment
Min Cost To Add New Roads
Online Assessment
Connect Ropes
Amazon Online Assessment
Pizza Shop
Google Phone
Least Common Ancestor Of Multiple Nodes
Amazon Phone Tree
Remove Duplicated IPv4 Addresses
Amazon Onsite
Fibonacci Base I
Google
Activate Fountain
Twitter Online Assessment
Reaching Point
Twitter Online Assessment
K-Difference
Twitter Online Assessment
Find Critical Nodes
Amazon Online Assessment
Zombie Matrix
Amazon HOT
Data Center Critical Connection
Amazon Online Assessment
Min Cost to Repair Edges (Minimum Spanning Tree II)
Amazon Online Assessment MST Graph
Rose Garden
Google Online Assessment
Minimum Number Of Decreasing Subsequence Partitions
Google Online Assessment Hard DP
Cut Binary Search Tree
Amazon Tree BST Hard LC
Subtree: Maximum Average Node
Amazon Online Assessment Medium Tree
Fill 2D Array
Google Online Assessment
Rearrange String
String
Pickup Coupon
Google Online Assessment
Tree Diameter
Google
Top N Buzzwords
Amazon Online Assessment HOT
Load Balancer
Amazon Online Assessment
Find Substrings
Amazon Online Assessment Hard
Partition String
Amazon Online Assessment String Medium

Ratings Threshold

Third-party companies that sell their products online are able to analyze the customer reviews for their products in real time. Imagine that there is creating a category called "five-star sellers" that will only display products sold by companies whose average percentage of five-star reviews per-product is at or above a certain threshold. Given the number of five-star and total reviews for each product a company sells, as well as the threshold percentage, what is the minimum number of additional fivestar reviews the company needs to become a five-star seller?

For example, let's say there are 3 products (n = 3) where productRatings = [[4,4], [1,2], [3, 6]], and the percentage ratings Threshold = 77. The first number for each product in productRatings denotes the number of fivestar reviews, and the second denotes the number of total reviews. Here is how we can get the seller to reach the threshold with the minimum number of additional five-star reviews:

  • Before we add more five-star reviews, the percentage for this seller is ((4 / 4) + (1/2) + (3/6))/3 = 66.66%
  • If we add a five-star review to the second product, the percentage rises to ((4 / 4) + (2/3) +(3/6))/3 = 72.22%
  • If we add another five-star review to the second product, the percentage rises to ((4 / 4) + (3/4) + (3/6))/3 = 75.00%
  • If we add a five-star review to the third product, the percentage rises to ((4/4) + (3/4) + (4/7))/3 = 77.38%

At this point, the threshold of 77% has been met. Therefore, the answer is 3 because that is the minimum number of additional five-star reviews the company needs to become a five-star seller.

Function Description

Complete the function fiveStarReviews in the editor below.

fiveStarReviews has the following parameters:

int productRatings[n][2]: a 2-dimensional array of integers where the ith element contains two values, the first one denoting fivestar[i] and the second denoting total[i]

int ratingsThreshold: the threshold percentage, which is the average percentage of five-star reviews the products need for the company to be considered a five-star seller

Returns:

int: the minimum number of additional five-star reviews the company needs to meet the threshold ratingsThreshold

Constraints

  • 1<=n<=200
  • 0 <= fivestar<total<=100
  • 1<=ratingsThreshold<100
  • The array productRatings contains only non-negative integers.

Python


def fiveStartReviews(productRatings, ratingsThreshold):