Problem
Count Unstable Processes
Learn this problemProblem statement
You are given three arrays of equal length: process, timestamp, and limit. Entry i records that process process[i] had limit limit[i] at time timestamp[i].
For each process, order its records by increasing timestamp. A process is unstable if its ordered limit sequence has at least one increase and at least one decrease between consecutive records.
Return the number of unstable processes.
Function
countUnstableProcesses(process: String[], timestamp: int[], limit: int[]) → intExamples
Example 1
process = ["A", "B", "A", "C", "D", "A"]timestamp = [10, 25, 30, 35, 15, 20]limit = [20, 18, 10, 8, 30, 27]return = 1Process A has records ordered by time 20 -> 27 -> 10, which includes both an increase and a decrease. The other processes are not unstable.
Example 2
process = ["A", "A", "B", "B", "B"]timestamp = [1, 2, 1, 2, 3]limit = [5, 7, 3, 2, 1]return = 0Process A only increases, and process B only decreases, so neither is unstable.
Constraints
1 <= process.length == timestamp.length == limit.length <= 2 * 10^5process[i]is a non-empty string.0 <= timestamp[i] <= 10^9-10^9 <= limit[i] <= 10^9- No process has two records with the same timestamp.
More IBM problems
- Parent Process NumberOA · Seen Jul 2026
- Request Retry CountOA · Seen Jul 2026
- Count Strictly Increasing Subsequences of Length 3OA · Seen Jul 2026
- Maximum Requests in a Time WindowOA · Seen Jul 2026
- Query Type Frequency WindowOA · Seen Jul 2026
- Minimum Number of Non-Empty Disjoint SegmentsOA · Seen Jul 2026
- Spam Text ClassificationOA · Seen Jul 2026
- Count Ideal NumbersOA · Seen Jun 2026