"Find Missing And Repeating" Code Answer's
You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "Find Missing And Repeating" answered properly. Developers are finding an appropriate answer about Find Missing And Repeating related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like Find Missing And Repeating. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on Find Missing And Repeating.
Find Missing And Repeating
// { Driver Code Starts
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
class Solution{
public:
long long *findTwoElement(int *arr, int n) {
long long N=n;
long long s=(N*(N+1))/2;
long long sm=(N*(N+1)*(2*N +1))/6;
for(int i=0;i<n;i++){
s-=arr[i];
long long k=arr[i];
sm-=k*k;
}
long long flag=sm/s;
long long mis=(flag+s)/2;
long long db=flag-mis;
long long*a=new long long (2);
a[0]=db;
a[1]=mis;
return a;
}
};
// { Driver Code Starts.
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
Solution ob;
auto ans = ob.findTwoElement(a, n);
cout << ans[0] << " " << ans[1] << "\n";
}
return 0;
} // } Driver Code Ends
All those coders who are working on the C++ based application and are stuck on Find Missing And Repeating can get a collection of related answers to their query. Programmers need to enter their query on Find Missing And Repeating related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about Find Missing And Repeating for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of Find Missing And Repeating while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "Find Missing And Repeating". Visit this developer's friendly online web community, CodeProZone, and get your queries like Find Missing And Repeating resolved professionally and stay updated to the latest C++ updates.