Hi! So this question was asked in bloomberg phone interview. I find it very confusing, so i'm wondering if the community over here could help anwer this question or atleast point to a similar question on leetcode:
"A tv show on a streaming service is "addictive" if atleast 70% of users have watched all the episodes of a show (10 episodes for each show in this problem). Given a log of show name, user id and episode number they watched, return the episode number at which the show gets "addictive" i.e the episode after which atleast 70% of users will finish watching till 10th episode.
void process_logs(string show, int episode, int user_id); //input is given by calling this
void print_results(); //should return the output
Initially I was given only the above problem statement. But after a long discussion of Q&A and clarifications, was able to extract the below information with examples:
Example:
show, episode, user_id
"BB", 4, 2 //userid 2 has watched BB until episode 4
"BB", 10, 6 //userid 6 has watched BB until episode 10
"BB", 5, 1
"BB", 6, 7
"BB", 10, 2
"BB", 10, 3
"BB", 10, 4
"BB", 10, 5
"GOT", 4, 3 //userid 3 has watched GOT until episode 4
"GOT", 6, 1 //userid 1 has watched GOT until episode 6
"GOT", 7, 3
"GOT", 8, 2
"GOT", 10, 4
"GOT", 10, 5
"GOT", 10, 6
"GOT", 10, 7
"GOT", 10, 1
output: format: show name, episode number
BB 5
GOT 7
Explanation:
For first output "BB 5"
There are total 7 users who have watched episode 5, out of whom only 5 users have watched all 10 episodes. So % of users that have watched till 10th episode after watching 5th episode are 71% (5/7) therefore answer is episode 5 -- as we can say that atleast 70% of people who have watched 5th episode will watch till 10th episode.
For second output "GOT 7"
There are 7 users have watched all 7 episodes; out of whom only 5 users have watched all 10 episodes. So % of users that have watched till 10th episode after watching 7th episode is 5/7 = 71% therefore answer is episode 7 -- as we can say that atleast 70% of people who have watched 7th episode will watch till 10th episode."
Thanks a lot in advance!