Why is my code not working(Python)


  • 0
    S

    Here is my code for this problem:

    class Solution:
       def twoSum(self, nums, target):
           """
           :type nums: List[int]
           :type target: int
           :rtype: List[int]
           """
           i=0
           j=1
           while i<=len(nums)-1:
               while j<=len(nums):
                   if nums[i]+nums[j]==target:
                       return i,j
                   else:
                       j+=1
               i+=1
    
    

    How can I fix this?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.