Suppose you are given 3 sorted arrays. Find three elements ( a , b , c ), one from each array, such that a + b = c .
Let the three given sorted arrays be array1 [ ], array2 [ ] and array3 [ ].
Time complexity = \( O(\underbrace{Length\ of\ array3}_{Outer\ for\ loop} \times \underbrace{(Length\ of\ array1+Length\ of\ array2)}_{Inner\ while\ loop})\) For simplicity, if we assume all the three arrays are of same length, say n , overall time complexity will be \( O(n^{2}) \). |