Pergunta de entrevista da empresa PagerDuty

Pair the elements of an array that sum up 100.

Respostas da entrevista

Sigiloso

23 de set. de 2016

Put them in a hashset and iterate them once, done. O(n).

1

Sigiloso

28 de mai. de 2018

its a two sum... :)

Sigiloso

25 de jan. de 2016

I tried to solve this question by sorting the array and pairing the first and last elements to see if the sum is 100 . If greater than 100 , decrease the end pointer else increase the start pointer. I was able to solve the problem in the less time of around ~22 mins of time. my logic couldnt cover one corner case. otherwise it is efficient with 0(n) complexity. Given few more minutes of time i would have been able to solve that too. The biggest mistake i did was not communicating my thought process, being a recent grad i was busy solving the problem immediately rather than talking about my approach. The interviewer sure did not understand my logic and i was not called for next round. I wish they gived me a chance !!!

1