Given an array A of integers, find any 3 of them that sum to any given T.
I saw this on some online post, which claims it has a O(NlogN) solution.
For 2 numbers, I know hashtable could help for O(N), but for 3 numbers, I cannot find one.
I also feel this problem sounds familar to some hard problems, but cannot recall the name and therefore cannot google for it. (While the worst is obviously O(N^3), and with the solution to 2 numbers it is really O(N^2) )
It does not really solve anything in the real world, just bugs me..
Any idea?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…