How can I access the first element of a pair if that pair lies at the ith index in an array?
Accessing pair elements
if arr[i] is pair then for getting first element you can use
arr[i].first
My code still throws an error with arr[i].first
the problem is that
arr[i] is not pair
arr is of type int not pair<int,int>
so instead of int arr[N];
use pair<int ,int> arr[N];
/bin/run.sh: line 4: 18 Bus error (core dumped) ./exe
now the code shows this error https://codeshare.io/5oAm1b