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
4mo

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!
Select
Add answer anonymously...

Popular interview questions of Software Developer

A Software Developer was asked 12mo agoQ1. What are the concepts of OOPS?
A Software Developer was asked 12mo agoQ2. What are the differences between Java and Python?
A Software Developer was asked Q3. Help Bob Out! - Validating IFSC Code Bob has just turned 18 and opened a bank ac...read more
Bottomline Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits