Ninja Competition Problem Statement

Ninja is organizing a coding competition where two teams compete at a time. To keep it fair and interesting, both teams must have an equal number of members. Ninja’s task is to form these two teams.

For this task, Ninja receives an integer 'N'. For each divisor 'D' of 'N' (including 1 and N), members are added as follows:

  1. To the first team if 'D' is even.
  2. To the second team if 'D' is odd.

Your task is to determine if Ninja can create two teams with equal members given 'N'.

Example:

Input:
N = 10
Output:
true
Explanation:

Divisors of 10 are: 1, 2, 5, 10.

The first team will have two members from divisors 2 and 10. The second team will have two members from divisors 1 and 5. Hence, the answer is true.

Constraints:

  • 1 <= T <= 100
  • 1 <= N <= 105
  • ΣN over all test cases doesn’t exceed 105
  • Time Limit: 1 sec
AnswerBot
5d

Check if Ninja can create two teams with equal members given an integer N and its divisors.

  • Iterate through all divisors of N and assign members to the first or second team based on whether the divisor...read more

Help your peers!
Add answer anonymously...
Bottomline Software Developer 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