You are analyzing user engagement patterns across different Netflix content to understand viewing behavior. This type of analysis helps Netflix optimize content recommendations and understand completion rates.
Given a list of viewing sessions, you need to:
Classify each session based on percentage watched
Find each user's dominant engagement pattern
Count how many users have each dominant pattern
Abandoned: Watched less than 25% of the content
Sampled: Watched 25% to 75% of the content (inclusive on both ends)
Completed: Watched more than 75% of the content
` viewing_data = [ {"account_id": "U1", "title_id": "T1", "title_runtime_secs": 3600, "watched_secs": 3500, "day_nbr": 1}, {"account_id": "U1", "title_id": "T2", "title_runtime_secs": 5400, "watched_secs": 5000, "day_nbr": 3}, {"account_id": "U2", "title_id": "T1", "title_runtime_secs": 3600, "watched_secs": 800, "day_nbr": 5}, {"account_id": "U2", "title_id": "T2", "title_runtime_secs": 2700, "watched_secs": 500, "day_nbr": 9}, {"account_id": "U3", "title_id": "T1", "title_runtime_secs": 3600, "watched_secs": 1800, "day_nbr": 2} ]
analyzeEngagementPatterns(viewing_data)
`
Calculate percentage watched for each session
Classify each session correctly based on percentage
Handle ties (any tied pattern can be chosen as dominant)
1 <= viewing_data.length <= 10^5
1 <= title_runtime_secs <= 10^6
0 <= watched_secs <= title_runtime_secs
All account_id and title_id values are non-empty strings