Doubt in a random practice problem

in the problem “https://practice.geeksforgeeks.org/problems/overlapping-intervals/0
My code -"#include<bits/stdc++.h>
using namespace std;
void Delete(int a[],int x,int n){
int i;
for (i=0; i<n; i++)
if (i == x)
break;

// If x found in array
if (i < n)
{
// reduce size of array and move all
// elements on space ahead
n = n - 1;
for (int j=i; j<n; j++)
a[j] = a[j+1];
}
}
int main()
{
//code
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;cin>>t;
while(t–){
int n;cin>>n;
int a[n],b[n],c[2*n];for(int i=0;i<n;i++) cin>>a[i]>>b[i];
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
if(a[i]<a[j]&&b[i]>b[j]){Delete(a,j,n);Delete(b,j,n);}
}
}
int count=0;
for(int i=0;i<n;i++) {c[count++]=a[i];}
for(int i=0;i<n;i++) {c[count++]=b[i];}
sort(c,c+count);
for(int i=0;i<count;i++) cout<<c[i]<<" “;
cout<<endl;
}
return 0;
}”
I want to ask that ,y logic is correct or not.

Hi @Ayusinha, pls save your code on ide.codingblocks.com and share the URL here so that we can help you out.

i only want to know that which we have to use in this problem-“https://practice.geeksforgeeks.org/problems/overlapping-intervals/0