smallest distance
find the smallest distance in a given array. const arr = [1, 4, 2, 2, 1, 5]; function smallestDistance(arr) { const distanceArray = []; for (let i = 0; i < arr.length; i++) { if (arr.lastIndexOf(arr[i]) !== arr.indexOf(arr[i])) { let distance = arr.lastIndexOf(arr[i]) - arr.indexOf(arr[i]) //get the distance distanceArray.push(distance); //push to new array } } distanceArray.sort() //sort consol..
Algorithms
2021. 1. 16. 21:27
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- code refactoring
- C++
- Object type casting
- java
- rest parameter
- javascript
- hackerrank javascript
- equals()
- math.max
- hackerrank
- string class in java
- Collection Framework
- algorithm
- hackerrank solution
- easy algorithm
- HashMap
- 프로그래머스 알고리즘문제
- math.abs
- HackerRank Algorithm
- hackerrank javascript solution
- easy javascript algorithm
- Javascript Algorithm
- repeat()
- substring()
- ... in Javascript
- compareTo()
- 알고리즘
- 프로그래머스
- 프로그래머스 알고리즘
- spring boot application
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함