A + B + C + D = K

Правка en1, от shivam565, 2021-10-29 11:01:43

We are given an array of n elements and I want to count the total no of such four variables with a sum equal to K, I tried it using multi-map where I store all key-value key(sum of pairs) and value(pair{i,j}) and then two-pointer, I am confused in the case when the sum of two pairs is equal to K, then where I will go (right to I, or left to j) cause If I move in both direction the time complexity will increase, and there are overlapping cases too if I store the frequency of each pair sum.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский shivam565 2021-10-29 11:01:43 510 Initial revision (published)