Longest Common Prime Subsequence Problem Statement
Imagine Ninja is tackling a puzzle during his long summer vacation. He has two arrays of integers, each with lengths 'N' and 'M'. Ninja's task is to determine the length of the longest subsequence that is common to both arrays and consists only of prime numbers.
Example:
Input:
T = 1
N = 4, M = 5
arr1 = [2, 3, 4, 5]
arr2 = [3, 5, 7, 11, 13]
Output:
2
Explanation:
The prime numbers that are common to both arrays are 3 and 5. Hence, the length of the longest common prime subsequence is 2.
Constraints:
- 1 <= T <= 5
- 1 <= N, M <= 5 * 102
- 1 <= arr1[i], arr2[i] <= 300
- Time Limit: 1 sec.
Note:
- A subsequence is a sequence that can be derived from another sequence by zero or more elements, without changing the order of the remaining elements.
- You don't need to print anything, the printing has already been taken care of. Just implement the given function.
Be the first one to answer
Add answer anonymously...
Top Cadence Design Systems Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Cadence Design Systems Software Developer
>
Cadence Design Systems Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app