Why I am getting core dumped error here in the IDE provided for the problem : Target Sum Triplet, while working correctly on sublime text.
My code :
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n;
cin>>n;
ll a[n];
for(ll i=0;i<n;i++){
cin>>a[i];
}
ll target;
cin>>target;
for(ll i=0;i<n;i++){
ll left = i+1;
ll right = n-1;
while(left < right){
ll sum = a[left] + a[right];
if(sum == (target - a[i])){
cout<<a[i]<<", β<<a[left]<<β and "<<a[right]<<endl;
left++;
rightβ;
}
else if(sum > (target - a[i])){
rightβ;
}
else{
left++;
}
}
}
return 0;
}