Count Unstable Processes
Updated
Problem 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 Online Assessment questions
- Missing IntervalsOA · Seen Nov 2026
- Count Peaks and ValleysOA · Seen Nov 2026
- Last Object Exit TimeOA · Seen Nov 2026
- Count Strictly Increasing Contiguous WindowsOA · Seen Nov 2026
- Total Each Letter's Count in an Encoded StringOA · Seen Nov 2026
- Count Servers With No Requests in a Time WindowOA · Seen Nov 2026
- Maximum Easy Tasks After RearrangingOA · Seen Nov 2026
- Tree Pythagorean TriplesOA · Seen Oct 2026
- Minimum Power-of-Two Removal OperationsOA · Seen Oct 2026
- Maximum Compatible Time WindowsOA · Seen Oct 2026