CarWale interview question

Find three unique elements resulting in target sum.

Interview Answer

Anonymous

4 Aug 2024

My first approach was to iterate array twice and in the inner loop maintain a hashmap to find triplets resulting in target sum. Here I made a mistake because instead of hashmap set is optimal data structure to be used. After explaining approach I was told to implement it using any online compiler.