Given a sorted integer array where the range of elements are in the inclusive range [lower, upper], return its missing ranges. For example, given [0, 1, 3, 50, 75], lower = 0 and upper = 99, return ["2", "4->49", "51->74&quo…
#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++) {…