We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
算法本身没问题,改一下比较好
public static int[] twoSum(int[] numbers, int target) { int[] result = new int[2]; Map<Integer, Integer> map = new HashMap<>(); for (int i = 0; i < numbers.length; i++) { if (map.containsKey(target - numbers[i])) { result[1] = i; result[0] = map.get(target - numbers[i]); return result; } map.put(numbers[i], i); } return result; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
算法本身没问题,改一下比较好
The text was updated successfully, but these errors were encountered: