Pergunta de entrevista da empresa Phenom

elements in an array, all of them appeared twice except one element which appeared once.. find that element

Respostas da entrevista

Sigiloso

19 de ago. de 2020

perform bit-wise XOR for all the elements of an array, then the result will be required element.

2

Sigiloso

22 de jun. de 2020

create a set. traverse through the array, find sum of the elements and put the elements in set and find the sum of the elements of the newly added elements to the set(exclude it off the sum) return 2*sumOfSet - sumOfArray

1