public class Solution { public int[] twoSum(int[] numbers, int target) { // IMPORTANT: Please reset any member data you declared, as // the same Solution instance will be reused for each test case. int[] results = new int[2]; for(int i = 0; i < numbers.length - 1; i++){ for(int j = i + 1; j < numbers.length; j++){ if(numbers[i] + numbers[j] == target){ results[0] = i + 1; results[1] = j + 1; return results; } } } return results; } }
相关文章
- 12-04LeetCode OJ 215. Kth Largest Element in an Array
- 12-04LeetCode-139-单词拆分
- 12-04leetcode 165. Compare Version Numbers
- 12-04【LeetCode】3. Longest Substring Without Repeating Characters
- 12-04LeetCode 第 165 场周赛
- 12-04开学第十四周.Two
- 12-04[LeetCode] 1376. Time Needed to Inform All Employees
- 12-04LeetCode每日一题——690. 员工的重要性
- 12-04第一次leetcode周赛总结
- 12-04LeetCode(7) - Reverse Integer