#include <bits/stdc++.h>
using namespace std;
int main(){
int nums[]={2,3,4,1,3,2};
int ans=0;
int n=sizeof(nums)/sizeof(int);
for(int i=0;i<n;i++){
int temp=abs(nums[i]);
if(nums[temp-1]<0){
ans+=temp;
}
else{
nums[temp-1]*=-1;
}
}
cout<<ans;
return 0;
}
Not compiling pls check the error
it is compiling check again
code link
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.