Panda Guru LogoPanda
Guru

LinkedIn OA

Round 1

Questions: A biological researcher is examining bacteria interactions, where some bacteria are poisonous to others. The samples are arranged consecutively in a row from 1 to n. Given a list detailing which bacteria are poisonous to others, determine the number of intervals within the row that contain only samples capable of coexisting.

Example:

n = 3 allergic = [2, 1, 3] poisonous = [3, 3, 1]

To determine relationships, the elements of:

The bacteria are arranged as 123. 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:

Returns:

Constraints:

Sample Case 0:

n = 4 allergic = [1, 2] poisonous = [3, 4]

Sample Output:

7

I was not able to solve this problem, leetcode community kindly help me solve this problem.

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.