Leetcode Array Question #1 Two Sum (Return Index) and #15 3Sums (return numbers).
Obviously, #1 can use HashTable to have a dictionary return index, no sorting needed. #15 , or #18 (4Sum) using sorting and two pointers to have a unique combination for numbers in the array.
I recently had an interview ask to return index of a 3Sum:
For example:
nums = [-1, 0, 1, 2, -1, -4]
Target = 0
Return: [
[0,1,2],
[0,3,4]
]
These are the index of the list of
[-1, 0, 1],
[-1, -1, 2]
Any solution can return index instead of numbers in the list? (Preferrbly Python solution) Looks like no sorting can be used.