Блог пользователя shivam565

Автор shivam565, история, 3 года назад, По-английски

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.

  • Проголосовать: нравится
  • -17
  • Проголосовать: не нравится