Two Sum asks for two indexes whose values add up to a target. The useful part is seeing why each approach costs what it costs.
A nested loop checks every pair. It is easy to write and it is O(n²). Fine for a tiny list, and the wrong default once the list is long.
Sorting a copy lets you walk inward from both ends. That is O(n log n), and you have to keep the original indexes if the problem asks for them.
One pass with a hash map stores each number as you go and checks whether its complement is already there. That is O(n) time and O(n) space. Duplicates such as [3, 3] work when you check before you insert.
3Sum uses the same complement idea, plus a sort so each pair is found with two pointers.