Validate Server Log Summary Counts
Updated
Problem statement
A server log is represented by logs. Each row is [timestamp, userId, action]. The rows are unordered, and repeated rows are separate events.
An analytics service returns summary, where each row is [userId, action, reportedCount]. Each user-action pair appears at most once in summary.
Return every incorrect pair as [userId, action, rawCount, reportedCount], where rawCount is computed from logs. A pair missing from either input has count 0. Sort the returned rows by userId, then by action. Return an empty array when the summary is completely correct.
Function
findLogSummaryDifferences(logs: String[][], summary: String[][]) → String[][]Examples
Example 1
logs = [["2026-10-10T10:00:00Z","u1","login"],["2026-10-10T10:03:00Z","u1","logout"],["2026-10-10T10:05:00Z","u1","login"]]summary = [["u1","login","1"],["u1","logout","1"]]return = [["u1","login","2","1"]]The raw log contains two login events for u1, but the summary reports one.
Example 2
logs = [["t1","u1","view"],["t2","u2","click"]]summary = [["u1","view","1"],["u2","click","1"],["u3","view","2"]]return = [["u3","view","0","2"]]The summary includes two view events for u3, although the raw log has none.
Example 3
logs = [["t3","u2","view"],["t1","u1","view"],["t2","u2","view"]]summary = [["u2","view","2"]]return = [["u1","view","1","0"]]The summary omits the one view event belonging to u1.
Constraints
0 <= logs.length <= 200000.- Every row of
logscontains exactly three non-empty strings: timestamp, user ID, and action. 0 <= summary.length <= 200000.- Every row of
summarycontains exactly three strings: user ID, action, and a decimal integer from0through2147483647. - Each user-action pair appears at most once in
summary. - User IDs and actions contain at most
50characters.
More Google Onsite Interview questions
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
- Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
- Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
- Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Transform Dotted Keys into a Nested MapProofpoint · ONSITE INTERVIEW
- Serialize and Deserialize a String Key-Value StoreByteDance · ONSITE INTERVIEWByteDance interview questions
- In-Memory Database QueriesOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
- Order Manager with Partial Cancellations and Indexed QueriesStripe · ONSITE INTERVIEWStripe interview questions
- Deep Merge with a Conflict ResolverAutodesk · ONSITE INTERVIEWAutodesk interview questions
- Number of AtomsAmazon · ONSITE INTERVIEW
- Server Log Summary and Minute AnomaliesNinjaTrader · PHONE SCREEN
- Insert an Employee into an Organization HierarchyWaymo · PHONE SCREENWaymo interview questions
- Party Windows and Dead Zone TimeScale AI · PHONE SCREENScale AI interview questions
- Common Words Across FilesMeta · PHONE SCREENMeta interview questions