
Asked in Cadence Design Systems
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 Software Developer Interview Questions Asked at Cadence Design Systems
Q. Given an array, reverse the order of its elements in place.
Q. How would you find the sum of two numbers in a linear array (both sorted and uns...read more
Q. Given the coordinates of a point and a rectangle, how would you determine if the...read more
Interview Questions Asked to Software Developer at Other Companies
Top Skill-Based Questions for Cadence Design Systems Software Developer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

