Sum of Even & Odd Digits

You need to determine the sum of even digits and odd digits separately from a given integer.

Input:

The first line of input is an integer T representing the number of test cases. Each test case consists of a single line with an integer N.

Output:

For each test case, output two space-separated integers: the sum of even digits and the sum of odd digits, respectively.

Example:

Input:
2
13245
2468
Output:
6 9
20 0

Constraints:

  • 1 <= T <= 5
  • 0 <= N <= 10^{18}

Note:

You do not need to print anything yourself. Just implement the function to return the required values.

AnswerBot
4mo

Given an integer, find the sum of even and odd digits separately.

  • Iterate through each digit of the integer and check if it is even or odd

  • Keep track of the sum of even and odd digits separately

  • Return t...read more

Anonymous
2y

We can also follow this approach: first perform mergeSort

Then do run a loop on sorted array and and for every index value find the required value by target - arr[i] ,

Then for evry required value -You...read more

Help your peers!
Select
Add answer anonymously...
Delta Air Lines SDE-2 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