swift3 solution


  • 0
    Z
    class Solution {
        func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
            for index in 0..<nums.count {
              let i = index + 1
              for index2 in i..<nums.count {
                  var sum = nums[index] + nums[index2]
                  if sum == target {
                      return [index ,index2 ]
                  }
              }   
            }
          
            return [0,0]
        }
    }
    

Log in to reply
 

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