Given an array, how do you find the number of pairs that sum to an even number?

AnswerBot
1y

Count the number of pairs in an array that sum to an even number.

  • Iterate through the array and check each pair of elements.

  • If the sum of the pair is divisible by 2, increment the count.

  • Return the coun...read more

Anonymous
1y

((cntEven * (cntEven – 1)) / 2) + ((cntOdd * (cntOdd – 1)) / 2)

Anonymous
2y

There can be a total of n(n-1) 2 numbers of total pairs from the given arrays number

Mritunjay Mishra
3y

It's can be done by the location and arithmetic operator with the help of if and else condition with a loop for the location of columns numbers in array and outer loop for changing the rows .

Manasa Reddy
3y

In order to get the pair sum as even, all the even elements will be paired with only even elements and all the odd elements will be paired with only odd elements and the count will be ((cntEven * (cnt...read more

Amit Singh
4y

If both number are of same type(even or odd) then their sum always give even no. And everytime increase count by 1. Otherwise no increment.

Aarti Baliyan
4y

The sum of two odd no always give a sum to even. Example:- 3+3=6, 3+5=8

 

Aqib Khan
5y

Add +2

Select
Add answer anonymously...

Flipkart Graduate Trainee interview questions & answers

A Graduate Trainee was asked Q. Implement a queue using stacks.
A Graduate Trainee was asked Q. Given an array, how do you find the number of pairs that sum to an even number?
A Graduate Trainee was asked Q. Given an array, how do you find the number of pairs that sum to an odd number?

Popular interview questions of Graduate Trainee

A Graduate Trainee was asked Q1. Implement a queue using stacks.
A Graduate Trainee was asked Q2. Given an array, how do you find the number of pairs that sum to an even number?
A Graduate Trainee was asked Q3. Given an array, how do you find the number of pairs that sum to an odd number?

Top HR questions asked in Flipkart Graduate Trainee

A Graduate Trainee was asked Q1. What are your strengths and weaknesses?
A Graduate Trainee was asked Q2. If you were to launch a new product (clothes in my case), what factors would you...read more
A Graduate Trainee was asked Q3. What is the one POR you enjoyed the most?
Flipkart Graduate Trainee 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