Group Users by Connect or Disconnect
Updated
Problem statement
Given a list users of records [name, action], group the names by action. Each action is Connect or Disconnect.
Return one row for each action that appears in the input, with rows in lexicographic order of action. A row starts with the action, followed by that action's names in input order. Repeated records stay repeated. If users is empty, return an empty list.
For example, records [Alice,Connect], [Bob,Disconnect], and [John,Connect] give the groups Connect: [Alice,John] and Disconnect: [Bob].
Function
groupUsers(users: String[][]) → String[][]Examples
Example 1
users = [["Alice","Connect"],["Bob","Disconnect"],["John","Connect"]]return = [["Connect","Alice","John"],["Disconnect","Bob"]]Alice and John have the action Connect, and Bob has Disconnect. Connect sorts before Disconnect, so its row comes first.
Example 2
users = [["Lee","Disconnect"],["Lee","Connect"],["Lee","Disconnect"]]return = [["Connect","Lee"],["Disconnect","Lee","Lee"]]Lee appears once under Connect and twice under Disconnect; occurrences remain in order.
Constraints
0 <= users.length <= 500.- Every record contains exactly two strings: a nonempty name and one of
ConnectorDisconnect. - Names contain
1through50ASCII letters, digits, or underscores and are case-sensitive.
More Atlassian Phone Screen questions
- Merge Overlapping IntervalsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Tennis Court SchedulingPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
- Longest Consistent Activity StreakPHONE SCREEN · Seen Sep 2026
- Music Player Operation SequencePHONE SCREEN · Seen Sep 2026
- Underline Shortest Unique SubstringsPHONE SCREEN · Seen Aug 2026
- Can a Dictionary Word Be Formed from Note Letters?PHONE SCREEN · Seen Feb 2026
- Word Path Moving Only Right or DownPHONE SCREEN · Seen Feb 2026
- Ordered Badge Entry and Exit ViolationsPHONE SCREEN · Seen Aug 2025
- Two Sum with an Ordered Index PairPHONE SCREEN · Seen Aug 2025
Similar questions at other companies
- Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
- Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Single-Condition Product FilterCrowdstrike · PHONE SCREENCrowdstrike interview questions
- Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
- Most Frequent NameAmazon · PHONE SCREEN
- Words with Repeated AnagramsThe Voleon Group · PHONE SCREEN
- Project JSON Fields into a Target FormatBooking.com · PHONE SCREEN
- Product Keyword SearchTesco · PHONE SCREEN
- Verify Words Sorted by a Custom AlphabetTrueFoundry · PHONE SCREEN
- Character Frequencies Across Nested String ListsSnowflake · PHONE SCREENSnowflake interview questions