C# solution 425 ms


  • 0
    P
    public class Solution {
        public int[] TwoSum(int[] nums, int target) {
            List<int> a =  new List<int>();
            for(int i=0; i<nums.Length; i++){
                for(int j = i+1; j<nums.Length; j++){
                    if((target-nums[i]).Equals(nums[j]) ){
                        a.Add(j);
                        a.Add(i);
                    }
                }
                
            }
            a.Sort();
            return a.ToArray();
        }
    }
    

Log in to reply
 

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