AMD Interview QuestionStudents
- 0of 0 votes
A group of scientists have broken down species DNA into sequences of integers. They determine that two species with the respective DNA sequences A and B are considered to be related if a non-decreasing sequence C of the same length can be found, such that Ci=Ai or Ci=Bi.
Given the DNA sequences for two species, help the scientists determine if they are related.
The first line contains an integer, T, the number of test cases.
For each test case:
The first line contains an integer, N, the length of the DNA sequence.
The second line contains a sequence of space-separated integers describing species A.
The third line contains a sequence of space-separated integers describing species B.
On a new line for each test case, print YES if a non-decreasing sequence of the same length can be found (i.e.: species are related) or NO if it cannot.
1 2 3
4 4 4
3 2 1
6 5 4
Test Case 1: We could have C=1 2 4
Test Case 2: No increasing sequence C is possible.
Test Case 3: We could have C=1 2.
Interview Type: Written Test