Find The Sum of Uncommon Numbers Given two integer arrays input1[ ] and input2[], extract the numbers which are present only in | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 8

Find The Sum of Uncommon Numbers Given two integer arrays input1[ ] and input2[], extract the numbers which are present only in

Find The Sum of Uncommon Numbers Given two integer arrays input1[ ] and input2[], extract the numbers which are present only in any one of the array (uncommon numbers). Calculate the sum of those numbers. Lets call it sum1 and calculate single digit sum of sum1, i.e keep adding the digits of sum1 until you arrive at a single digit. Return that single digit as output. Note: 1.Array size ranges from 1 to 10. 2.All the array elements are positive numbers. 3.Atleast one uncommon number will be present in the arrays. Example-1 input1: { 123, 45, 7890, 67, 2, 90 } input2: { 45, 7890, 123 } output: 67 + 2 + 90 = 159 1 + 5 + 9 => 15 1 + 5 => 6 Example-2 input1: {6, 7, 12, 70, 44} input2: {8, 6, 70, 44} output: 7 + 12 + 8 => 27 2 + 7 => 9

13th Sep 2021, 2:07 PM
Tøxïç Skíñfíé 😈
Tøxïç Skíñfíé 😈 - avatar
3 Answers
+ 1
You should really show your attempt first... There would be many ways to acheive the same thing (especially between languages and libraries). Here’s a quick/simple way using Python: listOne = [123, 45, 7890, 67, 2, 90] listTwo = [45, 7890, 123] notBoth = set(listOne).symmetric_difference(set(listTwo)) summed = str(sum(notBoth)) while len(str(summed)) > 1: tmp = 0 for i in summed: tmp += int(i) summed = str(tmp) print(summed)
13th Sep 2021, 3:32 PM
DavX
DavX - avatar
0
B_H_S_DIKO AISA H GYAN MAT PELO YHA FALTU KA MKL, 1 SAAL PHLE KA QUESTION MUJHE JHAMT MATLAB NI AB ISKE SOLUTION SE,AB BAR BAR LIKE OR ANSWER DEKE ISKA MUJHE NOTIFICATION MT BHJO,OR MKL TU ITNA HI GYANI H TO JAKE APNA PDH YHA KYA BAKCHOMDI KRRA KI IF HOMEWORK THEN DONE URSELF,RAMNDI ADMI KHUD HI KRNA HOTA TO YHA Q POST KRTA MAI CHUMTTAD.
10th Jun 2022, 3:24 PM
Tøxïç Skíñfíé 😈
Tøxïç Skíñfíé 😈 - avatar
- 5
if homeWork: self.toDo() return
13th Sep 2021, 2:22 PM
Coding Cat
Coding Cat - avatar