Two Sum
Problem Problem_Link My Answer 1 hour limit no search on internet Overview input : int[] nums, int target output : int[] My code class Solution { public int[] twoSum(int[] nums, int target) { int temp[] = new int[nums.length]; int rtn[] = new int[2]; for (int i = 0; i < nums.length; i++) { temp[i] = target - nums[i]; for (int j = 0; j < i; j++) { if (temp[j] == nums[i]) { rtn[0] = j; rtn[1] = i; return rtn; } } } rtn[0] = 0; rtn[1] = 0; return rtn; } } Time complexity : $O(n^2)$ Space complexity : $O(1)$ My result Runtime: 76 ms, faster than 12.