[자바스크립트로 구현한 알고리즘] 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
반응형
그리드형

💖 저자에게 암호화폐로 후원하기 💖

아이콘을 클릭하면 지갑 주소가자동으로 복사됩니다