Special Sum of Array Problem Statement
Given an array 'arr' containing single-digit integers, your task is to calculate the total sum of all its elements. However, the resulting sum must also be a single-digit number. To achieve this, repeatedly sum the digits of the result until a single-digit number is obtained.
Example:
Input:
[5, 8, 4, 9]
Output:
8
Explanation:
The sum of the elements is 26
. The sum of the digits 2 + 6 = 8
is a single-digit number.
Constraints:
1 <= T <= 100
1 <= N <= 10^3
0 <= arr[i] <= 9
- The sum of 'N' across all test cases does not exceed
10^5
.
Time Limit: 1 sec
.
Be the first one to answer
Add answer anonymously...
Top Bajaj Finserv Data Scientist interview questions & answers
Popular interview questions of Data Scientist
Top HR questions asked in Bajaj Finserv Data Scientist
Stay ahead in your career. Get AmbitionBox app
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
Get AmbitionBox app