First and Last Access Time per User
Updated
Problem statement
Each entry in logs has the form userId,resourceId,timestamp and records a user accessing a resource. For each user, return the minimum and maximum timestamp across all resources.
Return rows [userId,firstTimestamp,lastTimestamp], with timestamps written as decimal strings.
For this exercise, assume records have exactly three comma-separated fields without spaces, identifiers are nonempty case-sensitive alphanumeric strings, and timestamps are nonnegative integer seconds.
For this exercise, assume rows are ordered lexicographically by user identifier and an empty log produces an empty result.
Function
accessRanges(logs: String[]) → String[][]Examples
Example 1
logs = ["bob,r1,10","amy,r2,20","bob,r3,2","amy,r1,40"]return = [["amy","20","40"],["bob","2","10"]]Bob spans 2 through 10 across resources; Amy spans 20 through 40. Rows are sorted by user.
Example 2
logs = ["u,resource,7"]return = [["u","7","7"]]One event supplies both endpoints.
Constraints
- For this exercise, assume
0 <= logs.length <= 10^4. - Identifier lengths are between
1and30. - Timestamps are integers from
0through10^9.
More Indeed Phone Screen questions
- Insert into an Unrolled Linked ListPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Course Completion OrderPHONE SCREEN · Seen May 2025
- Recipes You Can PreparePHONE SCREEN · Seen May 2025
- Rotting Orange PropagationPHONE SCREEN · Seen May 2025
- Courses Shared by Every Student PairPHONE SCREEN · Seen Aug 2022
- Most Accessed Resource in Five MinutesPHONE SCREEN · Seen Jul 2022
- Resource Transition GraphPHONE SCREEN · Seen Jul 2022
- Count Disappearing Connected TilesPHONE SCREEN · Seen Jul 2022
- First Dictionary Word from Note LettersPHONE SCREEN · Seen Jul 2022
- Word Path Moving Only Right or DownPHONE SCREEN · Seen Jul 2022
Similar questions at other companies
- Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
- Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
- First Letter to Appear TwiceCisco · PHONE SCREENCisco interview questions
- Halfway Course in a Single TrackCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Single-Condition Product FilterCrowdstrike · PHONE SCREENCrowdstrike interview questions
- Summarize Server Healthcheck LogsNVIDIA · PHONE SCREENNVIDIA interview questions
- Known Words Matching Phone DigitsLinkedIn · PHONE SCREENLinkedIn interview questions
- First Non-Repeated CharacterDell Technologies · PHONE SCREENDell Technologies interview questions
- Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
- First Non-Repeating CharacterGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions