FastPrepTranscript Window Metrics

Transcript Window Metrics

Sesame logoSesame● MediumFULLTIMEPHONE SCREEN
Learn

Problem statement

Transcript events arrive in order. Event i has user userIds[i] and transcript length lengths[i].

For every contiguous window of exactly windowSize events, return one row [maximumTranscriptLength, distinctUserCount]. Rows must follow window order.

Function

transcriptWindowMetrics(userIds: String[], lengths: int[], windowSize: int) → int[][]

Examples

Example 1

userIds = ["a","b","a","c"]lengths = [4,7,5,9]windowSize = 3return = [[7,2],[9,3]]

The first window has users a and b; the second has a, b, and c.

Example 2

userIds = ["u","u","v"]lengths = [2,8,1]windowSize = 2return = [[8,1],[8,2]]

The maximum stays 8 while the distinct-user count changes.

Example 3

userIds = ["x","y"]lengths = [0,3]windowSize = 1return = [[0,1],[3,1]]

A one-event window always has one distinct user.

Constraints

  • 1 <= windowSize <= userIds.length == lengths.length <= 100000.
  • 0 <= lengths[i] <= 1000000000.
  • User IDs are nonempty strings.
See Sesame hiring insights
public int[][] transcriptWindowMetrics(String[] userIds, int[] lengths, int windowSize) {
    // Return {maximumLength, uniqueUsers} for each window.
}
userIds["a","b","a","c"]
lengths[4,7,5,9]
windowSize3
expected[[7,2],[9,3]]
Checking account…