LeetCode 01 Two Sum swift

class TwoSum {
    func sumTow(nums: [Int], target: Int)->[Int]{
        
        var ret:[Int]=[0,0];
        
        for (var x=0;x<nums.count;x++){
            for(var y=x+1;y<nums.count;y++){
                if(target==nums[x]+nums[y]){
                    ret[0]=x+1
                    ret[1]=y+1
                }
            }
        }
        return ret;
    }
}

 

posted @ 2016-01-22 00:17  toon的泥瓦匠  阅读(474)  评论(0编辑  收藏  举报