Count Distinct Message Mentions
Updated
Problem statement
Given member IDs and messages, a mention group is a whitespace-delimited token beginning with @; its remainder may contain comma-separated IDs.
Count each member at most once per message, ignore unknown or unprefixed IDs, and include zero-count members. Return id=count strings sorted by count descending, then ID ascending.
Function
countMemberMentions(members: String[], messages: String[]) → String[]Examples
Example 1
members = ["id1","id2","id8"]messages = ["@id1 @id8,id8","hello @id8"]return = ["id8=2","id1=1","id2=0"]id8 is counted once in each message despite its duplicate first-message mention.
Example 2
members = ["a","b"]messages = ["a @b"]return = ["b=1","a=0"]The unprefixed a is ignored.
Constraints
1 <= members.length,messages.length <= 100000- Member IDs contain letters and digits and contain no commas or spaces.
More ZipRecruiter Online Assessment questions
- Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Simulate Orchard Rot SpreadOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
Similar questions at other companies
- Decode Words with Anagram KeysCresta · OACresta interview questions
- Longest String ChainVisa · OAVisa interview questions
- Frequently Bought TogetherAmazon · OA
- Maximize Palindromic WordsSquarepoint Capital · OASquarepoint Capital interview questions
- Aggregate Paginated Project Run RecordsReplit · OA
- Parse and Filter Chargeback DisputesStripe · OAStripe interview questions
- Count User Logins 🌿 (Singapore)PayPal · OAPayPal interview questions
- Largest Lexicographical Substring 🌿Google · OAGoogle interview questions
- Rank Common Translation MistakesDuolingo · OADuolingo interview questions
- Aggregate Investment Ownership from CSVCarta · OA · PHONE SCREEN