← ALL NOTES
Array

18. 4Sum

4Sum is 3Sum with one more layer: fix two outer elements with nested loops, then two-pointer the remaining pair in the sorted tail. Sorting earns its keep twice over — it steers the pointers and…

Loading…