Given an array of integers, every element appears thrice except for one which occurs once. Find that element which does not appear thrice.
Answers
Answered by
0
hey here is your answer
hope you like this answer
let arr[] = {12, 1, 12, 3, 12, 1, 1, 2, 3, 3} Required no = ( 3*(sum_of_array_without_duplicates) - (sum_of_array) ) / 2 = ( 3*(12 + 1 + 3 + 2) - (12 + 1 + 12 + 3 + 12 + 1 + 1 + 2 + 3 + 3))/2 = ( 3* 18 - 50) / 2 = (54 - 50) / 2 = 2 (required answer)
hope you like this answer
let arr[] = {12, 1, 12, 3, 12, 1, 1, 2, 3, 3} Required no = ( 3*(sum_of_array_without_duplicates) - (sum_of_array) ) / 2 = ( 3*(12 + 1 + 3 + 2) - (12 + 1 + 12 + 3 + 12 + 1 + 1 + 2 + 3 + 3))/2 = ( 3* 18 - 50) / 2 = (54 - 50) / 2 = 2 (required answer)
Similar questions