KaranTheGreat's blog

By KaranTheGreat, history, 4 weeks ago, In English,

Example : [4,2,2,2,2], k=8

Answer : — (1)

As only 1 quadruple(2+2+2+2=8) exists whose sum is '8' :-)

I know the brute-force O(n^4) algorithm , I even know an O(n^2.log(n)) algorithm , but it unfortunately does not work with duplicate elements :-(

Any better-efficient way to solve it ? :-)

Constraints:- Length of array can be as long as 10^5 and array can consist of duplicate elements as well.



4 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Please write the constrains and your O(N^2.log(N)) algorithm so you can get help easier.

4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by KaranTheGreat (previous revision, new revision, compare).