Find kth missing integer and redundant operations
Company: Point72
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Take-home Project
You are given two independent coding tasks.
## Task 1: K-th missing number
You are given an integer array `nums` (not necessarily sorted) containing **distinct** positive integers, and an integer `k`.
Define the **missing numbers** as the positive integers that do **not** appear in `nums`.
**Return the k-th smallest missing positive integer.**
**Constraints (representative of an “optimal required” setting):**
- `1 <= n <= 2e5`
- `1 <= nums[i] <= 1e9` (distinct)
- `1 <= k <= 1e9`
**Example:**
- `nums = [2, 3, 7, 11], k = 5`
- Missing positives are `1, 4, 5, 6, 8, 9, 10, 12, ...`
- Answer: `8`
## Task 2: Count redundant operations within a time window
You are given two arrays of equal length `ops[]` and `times[]` describing a log of events, where:
- `ops[i]` is a string operation name (e.g., `"login"`, `"refresh"`)
- `times[i]` is the event time as an integer timestamp (seconds)
You are also given an integer window size `W` (seconds).
An event at index `i` is considered **redundant** if there exist **two earlier events** `j < k < i` such that:
- `ops[j] == ops[k] == ops[i]`
- `times[i] - times[j] <= W` (i.e., 3 occurrences of the same operation happen within a `W`-second window ending at `times[i]`)
**Return the total number of redundant events in the log.**
**Assumptions/notes:**
- The input may not be sorted; you may sort by time if needed.
- If multiple events share the same timestamp, treat earlier indices as earlier events.
**Example:**
- `ops = ["A","B","A","A","A"], times = [1,2,3,4,10], W = 5`
- The event at time `4` is redundant because `A` occurred at times `1,3,4` within 5 seconds.
- The event at time `10` is **not** redundant for window `W=5`.
- Answer: `1`
Quick Answer: This paired question evaluates array and algorithmic skills — specifically order-statistics and missing-number reasoning for the k-th missing positive, and time-window aggregation with frequency tracking for detecting redundant log events — within the coding & algorithms domain.