티스토리 뷰
Solution in Javascript
const p = [4, 2, 5, 1, 3];
function permutationEquation(p) {
const arr=[];
for (let i = 1; i <= p.length; i++) {
arr.push(p.indexOf(p.indexOf(i)+1)+1);
}
console.log(arr);
}
permutationEquation(p);
Reference
www.hackerrank.com/challenges/permutation-equation/problem
Sequence Equation | HackerRank
Find some y satisfying p(p(y)) = x for each x from 1 to n.
www.hackerrank.com
'Algorithms' 카테고리의 다른 글
Equalize the Array (0) | 2020.12.11 |
---|---|
Invert Binary Tree (0) | 2020.11.30 |
Viral Advertising (0) | 2020.10.22 |
Angry Professor (0) | 2020.10.19 |
Beautiful Days at the Movies (0) | 2020.10.18 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 프로그래머스
- ... in Javascript
- javascript
- code refactoring
- algorithm
- math.abs
- Object type casting
- equals()
- hackerrank solution
- 프로그래머스 알고리즘
- easy algorithm
- Collection Framework
- hackerrank javascript solution
- math.max
- HackerRank Algorithm
- hackerrank javascript
- easy javascript algorithm
- java
- hackerrank
- spring boot application
- HashMap
- Javascript Algorithm
- 알고리즘
- C++
- compareTo()
- 프로그래머스 알고리즘문제
- substring()
- string class in java
- repeat()
- rest parameter
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
글 보관함