Hello,

I just get started on Python last week and am learning by coding. Here's two piece of code that I came up with for 3sum question, both are erring in TLE(Time Limit Exceed) on my end, and I can't figure out where went wrong at present, I would love to learn from any member of the community and any suggestion to optimize is greatly appreciated.

I tried sorted/sort(), range/xrange, and they both result in TLE.

'''

result=[]

```
sl=sorted(nums)
#0123456789
#i..l.....r
for i in xrange(len(sl)-2):
l=i+1
r=len(sl)-1
while(l<r):
sum_=sl[i]+sl[l]+sl[r]
if sum_<0:
l=l+1
elif sum_>0:
r=r-1
else:
sublist=[sl[i],sl[l],sl[r]]
if not sublist in result:
result.append(sublist)
l=l+1
return result
for i in xrange(len(sl)):
target = -sl[i]
for j in xrange(i+1,len(sl)):
x=sl[j]
if target-x in sl[j+1:len(sl)]:
if [-target,x,target-x] not in result:
result.append([-target,x,target-x])
return result
```

'''