Subtopic: k pointers
思路出发点,分解问题的方式并没有任何改变,start from brute force
for all the tuples (i, j, k, l), where i in a, j in b, k in c, l in d;
Question 3.0. Given two sorted arrays A and B, if there exist two numbers a from A and b from B, such that a+ b = target
分解A[i] + B[j] ?= target
移动方向?
当j往左边移动的时候
B[j]减少?
A[i] = target - B[j]增大
i往右移动
相向而行的双指针
implementation: we cannot miss any possibe j?
Question 3.1 What about 3 sorted arrays? a+ b+ c = target from A, B, C
分解 A[i] + B[j] + C[k] = target
分解方式:固定k
for each K
Question 3.2 What about k sorted arrays?
Last updated