"Find Missing And Repeating equation based code" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "Find Missing And Repeating equation based code" answered properly. Developers are finding an appropriate answer about Find Missing And Repeating equation based code related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like Find Missing And Repeating equation based code. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on Find Missing And Repeating equation based code.
Find Missing And Repeating equation based code
#include <bits/stdc++.h>
using namespace std;
// most of you were taking int so here,overflow is occuring so take long long.
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;
}
};
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;
}
All those coders who are working on the Whatever based application and are stuck on Find Missing And Repeating equation based code can get a collection of related answers to their query. Programmers need to enter their query on Find Missing And Repeating equation based code related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about Find Missing And Repeating equation based code for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of Find Missing And Repeating equation based code while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "Find Missing And Repeating equation based code". Visit this developer's friendly online web community, CodeProZone, and get your queries like Find Missing And Repeating equation based code resolved professionally and stay updated to the latest Whatever updates.