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.

Anonymous
1y

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