[자바스크립트로 구현한 알고리즘] Sum of two lowest positive integers

남양주개발자

·

2016. 10. 16. 20:04

728x90
반응형



Description: 


Create a function that returns the sum of the two lowest positive numbers given an array of minimum 4 integers. No floats or empty arrays will be passed. 


For example, when an array is passed like [19,5,42,2,77], the output should be 7. [10,343445353,3453445,3453545353453] should return 3453455. 


Hint: Do not modify the original array.




전과 비슷한 문제입니다. 이번 문제는 배열에서 가장 낮은 숫자 2개를 구해서 그 숫자 2개를 더한 값을 return 하는 문제입니다. 조금 어렵게 생각했네요. 조금만 더 쉽게 생각하면 정말 간단하게 풀 수 있는 문제였는데요... 창의적이지 못한 저의 머리를 탓하면서...



728x90
반응형
그리드형

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

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