**QUESTION**

Text

Image

A biological researcher is studying the interactions of various bacteria. Some of the bacteria are poisonous to others. All of the samples are arranged in a row, numbered consecutively from 1 to $n$ in order. Given a list of which bacteria are poisonous to others, determine the number of intervals of samples that contain only samples that can coexist. Example \[ n=3 \] allergic $=[2,1,3]$ poisonous $=[3,3,1]$ To determine relationships, the elements of poisonous[O] -> allergic[O] so 3 is poisonous to 2 poisonous[1] -> allergic[1] so 3 is poisonous to 1 poisonous[2] -> allergic[2] so 1 is poisonous to 3 The bacteria are arranged as 12 3. An interval must be contiguous and the samples may not be reordered, like a subarray. All of the possible intervals are (1), (2), (3), (1, $2),(2,3),(1,2,3)$. Since the poisonous bacteria need to be kept apart from those that are allergic to them, the only valid intervals are (1), (2), (3), (1, 2). No intervals can contain both bacteria 1 and 3 or bacteria 2 and 3 . There are 4 valid intervals. Function Description Complete the function bioHazard in the editor below. bioHazard has the following parameters: int $n$ : the number of unique bacteria types int allergic [m]: allergic[i] is allergic to poisonous[i] int poisonous $[\mathrm{m}]$. the toxic bacteria Returns: int: the number of intervals made up only of bacteria that can coexist Language JavaScript (Node.js) G Autocomplete Ready () Test Custom Run Run Submit

not too sure how to implement this function. can be done in any language, just looking for the logic