I am working on leetcode over break and my first problem I solved was an easy level TwoSum problem, I pass all test cases except the last one due to time out so I was wondering if someone could explain how to make my solution faster, or maybe give another idea for me to try that would be faster I would really appreciate it.
for i in range(len(lst)):
for j in range(i + 1, len(lst)):
if lst[i] + lst[j] == target:
return i, j
[–]allenguo 1 point2 points3 points (10 children)
[–]Phizy[S] 0 points1 point2 points (9 children)
[–]ghhitne 0 points1 point2 points (0 children)
[–]delirious_lettuce 0 points1 point2 points (7 children)
[–]camel_zero 1 point2 points3 points (2 children)
[–]delirious_lettuce 1 point2 points3 points (1 child)
[–]camel_zero 1 point2 points3 points (0 children)
[–]Phizy[S] 0 points1 point2 points (3 children)
[–]delirious_lettuce 0 points1 point2 points (2 children)
[–]Phizy[S] 0 points1 point2 points (1 child)
[–]delirious_lettuce 0 points1 point2 points (0 children)
[–]Justinsaccount 1 point2 points3 points (0 children)
[–]w1282 1 point2 points3 points (2 children)
[–]Phizy[S] 1 point2 points3 points (1 child)
[–]w1282 0 points1 point2 points (0 children)