Pergunta de entrevista da empresa Ivanti

Find the 2 values in an array that gives a particular sum - not with 2 for loops.

Respostas da entrevista

Sigiloso

21 de dez. de 2021

same experience no feedback no come back

Sigiloso

13 de ago. de 2022

That's an easy one. Declare a hashset. Go through each item, check if the number exists in the hashset. If it does, return the two numbers that would add up to the sum. If it doesn't add the value of the sum minus the number you just found to the hashset if you reach the end of the array and you haven't returned anything, the sum is not in the array.