Sequence Equation | HackerRank

 https://www.hackerrank.com/challenges/permutation-equation/problem

#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int p[n+1];
    for(int i=1;i<=n;i++){
        int k;
        cin>>k;
        p[k]=i;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<p[p[i]]<<endl;
    }
    return 0;
}

Comments

Popular posts from this blog

Perfect Peak of Array

Is Rectangle?

Sort array with squares!