Company: Uber_all
Difficulty: medium
Biohazard Problem Description A biological researcher is studying bacteria interactions where certain bacteria are poisonous to others. The samples are arranged consecutively in a row numbered from 1 to n. Given lists detailing which bacteria are poisonous to others, your task is to determine the number of intervals within the row that contain only samples capable of coexisting. A pair of bacteria, poisonous[i] and allergic[i] , cannot coexist in the same interval. This means any interval containing both poisonous[i] and allergic[i] is invalid. Examples Example 1: Input: n = 3, allergic = [2, 1, 3], poisonous = [3, 3, 1] Output: 4 Explanation: The poisonous relationships are: Bacteria 3 is poisonous to Bacteria 2. Bacteria 3 is poisonous to Bacteria 1. Bacteria 1 is poisonous to Bacteria 3. The bacteria are arranged in a row: [1, 2, 3]. The pairs that cannot coexist are (3, 2) and (3, 1). The valid intervals (subarrays of [1, 2, 3]) are those that do not contain any of these pairs. The