Two pointers is one of the most effective patterns in coding interviews. The idea: use two indices that move through the array in a coordinated way. Sometimes they start at opposite ends and move toward each other. Sometimes they both start at the beginning, with one moving faster. Sometimes one defines the start of a window, the other the end. This pattern turns nested loops into single passes. If you see a problem that seems to need checking all pairs, think two pointers.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/maang-interview-prep/two-pointers-sliding-window/intro
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████████████████████████████████████████████████████████████████████████████████