Prime Time Again Problem Statement
You are given two integers DAY_HOURS
and PARTS
. The integer 'DAY_HOURS' represents the number of hours in a day, and the day can be divided into 'PARTS' equal parts. Your task is to determine the total instances of equivalent prime groups. A prime group refers to a pair of hours that are both prime and measure the same equivalent time from the start of the day, but each hour is in a different part of the day.
Example:
Input:
DAY_HOURS = 20, PARTS = 2
Output:
2
Explanation:
The day can be represented in parts as follows:
1 2 3 4 5 6 7 8 9 10 - Part 1
11 12 13 14 15 16 17 18 19 20 - Part 2
The prime groups are (3, 13) and (7, 17), as both elements in each pair are prime numbers.
Constraints:
1 ≤ T ≤ 100
10 ≤ DAY_HOURS ≤ 5 * 103
2 ≤ PARTS ≤ 103
- The day should be evenly divided by parts (i.e.,
DAY_HOURS % PARTS == 0
). - Time Limit: 1 second
Note:
1. The day starts at hour 1 and ends at hour 'DAY_HOURS'.
2. Each hour of the prime group must be from different parts of the day.
3. If there are no equivalent prime groups, return zero.
4. The number of hours per part must be a natural number.
Find total instances of equivalent prime groups in a day divided into equal parts.
Iterate through each part of the day and check for prime pairs in different parts
Use a helper function to check if a n...read more
Top TCS SDE-2 interview questions & answers
Popular interview questions of SDE-2
Reviews
Interviews
Salaries
Users/Month