#include <bits/stdc++.h> using namespace std; const int N = 1e6,INF = 0x3f3f3f3f; int a[N]; int n,x; void fun(int n) { int left = 0, right = n-1; while(left < right) { int ans=a[left] + a[right]; if(ans == x) { cout<<a[left]<<' '<&…
public static void main(String[] args) { int[] a = {1,2,2,3,3,4,5,6}; int m = 6; normal(a, m); } //正确思路 private static void normal(int[] a, int m) { Map<Integer,Integer> b = new HashMap<Integer, Integer>(); for(int i = 0;i < a.length;i++) {…