📌  相关文章
📜  javascript代码示例中的序列方程hackerrank解决方案

📅  最后修改于: 2022-03-11 15:03:35.132000             🧑  作者: Mango

代码示例1
// sequence equation hackerrank solution in javascript
function permutationEquation(p) {
    // Write your code here
    let arr = [];
    let index = 0;
    let value = 0;
    for(let i =1; i<=p.length; i++){
        index = p.findIndex(item => item == i);
        value = p.indexOf(index + 1) + 1;
        arr.push(value);
    }
    return arr;
}