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.
Examples
01 · Example 1
process = ["A", "B", "A", "C", "D", "A"] timestamp = [10, 25, 30, 35, 15, 20] limit = [20, 18, 10, 8, 30, 27] return = 1
Process A has records ordered by time 20 -> 27 -> 10, which includes both an increase and a decrease. The other processes are not unstable.
02 · Example 2
process = ["A", "A", "B", "B", "B"] timestamp = [1, 2, 1, 2, 3] limit = [5, 7, 3, 2, 1] return = 0
Process 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
- Count Descending SubarraysOA · Seen Apr 2026
- Count Power Products in RangeOA · Seen Apr 2026
- Minimum Operations to Make Alternating Binary StringSeen Feb 2026
- Minimum Number of Non-Empty Disjoint SegmentsSeen Feb 2026
- Longest Balanced Binary SubarrayOA · Seen Feb 2026
- Process Execution TimeOA · Seen Nov 2025
- Service Timeout DetectionOA · Seen Nov 2025
- Get Minimum OperationsSeen May 2025
public int countUnstableProcesses(String[] process, int[] timestamp, int[] limit) {
// write your code here
}process["A", "B", "A", "C", "D", "A"]
timestamp[10, 25, 30, 35, 15, 20]
limit[20, 18, 10, 8, 30, 27]
expected1
sign in to submit