One idea
Two pointers and sliding windows avoid checking every pair or every subarray again and again.
Move only the pointer that can still improve the answer. This is why these patterns are usually linear after sorting, or linear on the original array.
When to use
Use two pointers when the problem has a sorted array, a pair condition, or two ends of a sequence. Common examples: pair sum in a sorted array, remove duplicates, reverse vowels, container with most water.
Use sliding window when the answer is a contiguous part. Common examples: maximum sum of k elements, longest substring without repeating characters, smallest subarray with sum at least target.