Code: https://ide.codingblocks.com/s/412720
Problem: https://hack.codingblocks.com/app/contests/1975/21/problem
kindly correct my code .Not giving correct output
Code: https://ide.codingblocks.com/s/412720
Problem: https://hack.codingblocks.com/app/contests/1975/21/problem
kindly correct my code .Not giving correct output
Hey @kaustub
#include<iostream>
using namespace std;
int Reverse(int *a,int n,int i,int *f){
//Base case
if(i==n){
return 0;
}
//Recursive case
int val=a[i];
f[val]=i;
return Reverse(a,n,i+1,f);
}
int main() {
int a[1000],f[1000];//added f as array
int n;//removed f as int
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
Reverse(a,n,0,f);
for(int i=0;i<n;++i)//added this
cout<<f[i]<<" ";
return 0;
}
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.