I would like to ask about the solution to Two sums.
My idea is just to return i,j which goes trough for cycles as indices.
def two_sum(L, target): for i in range(len(L)): for j in range(i+1, len(L)-1): result = L[i] + L[j] if result == target: return [i, j] return -1
What I don’t understand is why should we used a dictionary in the solution of this exercise.
Does it bring any benefit?
Now I get it, my solution will not work with an empty list or a list with 1 element.
Thanks for reaching out.
Please accept my apologies for the delayed response.
Thank you for letting us know you can proceed with the course!
Good luck and please feel free to post another question should you encounter any difficulties. Thank you.
The 365 Team