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

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

class - Kivy: how to instantiate a dynamic classes in python -

python - mayavi mapping a discrete colorbar on a surface -