1class Solution {2public int[] twoSum(int[] nums, int target) {3int[] answer = new int[2];4// Two for loops for selecting two numbers and check sum equal to target or not56for (int i = 0; i < nums.length; i++) {7for (int j = i + 1; j < nums.length; j++) {8// j = i + 1; no need to check back elements it covers in i;9if (nums[i] + nums[j] == target) {10// Check sum == target or not11answer[0] = i;12answer[1] = j;13return answer;14}15}16}17return null;18}19}