[자바스크립트로 구현한 알고리즘] Highest and Lowest
남양주개발자
·2016. 9. 18. 14:05
728x90
반응형
In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number.
Example:
highAndLow("1 2 3 4 5"); // return "5 1"
highAndLow("1 2 -3 4 5"); // return "5 -3"
highAndLow("1 9 3 4 -5"); // return "9 -5"
Notes:
· All numbers are valid Int32, no need to validate them.
· There will always be at least one number in the input string.
· Output string must be two numbers separated by a single space, and highest number is first.
자바스크립트 기능을 사용해서 조금 더 간단한 로직으로 바꿔보겠습니다.
728x90
반응형
그리드형
'Computer science > 알고리즘' 카테고리의 다른 글
[자바스크립트로 구현한 알고리즘] Mumbling (0) | 2016.09.19 |
---|---|
[자바스크립트로 구현한 알고리즘] Get the Middle Character (0) | 2016.09.18 |
[자바스크립트로 구현한 알고리즘] Complementary DNA (0) | 2016.09.17 |
[자바스크립트로 구현한 알고리즘] Stringy Strings (0) | 2016.09.17 |
[자바스크립트로 구현한 알고리즘] Disemvowel Trolls (0) | 2016.09.17 |