algorithm - Given 3 sorted arrays A, B, C and number S, find i, j, k such that A[i] + B[j] + C[k] = S -


I just learned how to solve it in O (n ^ 2 log n) For each A [i]: For every B [J]: If A [I] + B [J] + C Birrinary Search (The time taken to handle every AR is the same):

  S - A [A] - B [J]] == S: Returns (I, J, K)  

To fix this, O (n ^ 2) to improve the time or the above algorithm?

if arrays are non-negative, * you * all 3 arrays are s => [N] & gt; S [Aidx] + B [BIDX]> S

Similarly,

Comments

Popular posts from this blog

python - Strange behavior using PyQt4's 'pyqtSlot' decorator before another decorator -

c# - UnhandledExceptionMode.ThrowException for AppDomain.UnhandledException -

c# - Process.Kill() returns access denied -