Prime with 3 Factors Problem Statement

You are provided with an array ARR consisting of 'N' positive integers. Your task is to determine if each number in the array ARR has exactly 3 factors.

You need to return an array with '0' and '1', where '0' means that ARR[index] does not have exactly 3 factors, and '1' means ARR[index] indeed has exactly 3 factors.

Example:

Input:
N = 4, ARR = [3, 5, 4, 2]
Output:
[0, 0, 1, 0]
Explanation:

For the given input,

  • 3 has factors: 1, 3 (2 factors).
  • 5 has factors: 1, 5 (2 factors).
  • 4 has factors: 1, 2, 4 (3 factors).
  • 2 has factors: 1, 2 (2 factors).

Hence, the resulting array is [0, 0, 1, 0].

Constraints:

  • 1 ≤ T ≤ 10
  • 1 ≤ N ≤ 106
  • 1 < ARR[index] ≤ 1012
  • Time Limit: 1 second
Be the first one to answer
Add answer anonymously...
Adobe Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter