Computer science/알고리즘

[자바스크립트로 구현한 알고리즘] Remove the minimum

남양주개발자 2016. 10. 14. 09:37
728x90
반응형


Description: 


The museum of incredible dull things The museum of incredible dull things wants to get rid of some exhibitions. Miriam, the interior architect, comes up with a plan to remove the most boring exhibitions. She gives them a rating, and then removes the one with the lowest rating. However, just as she finished rating all exhibitions, she's off to an important fair, so she asks you to write a program that tells her the ratings of the items after one removed the lowest one. Fair enough. Task Given an array of integers, remove the smallest value. If there are multiple elements with the same value, remove the one with a lower index. If you get an empty array/list, return an empty array/list. Don't change the order of the elements that are left. 


Examples 


removeSmallest([1,2,3,4,5]) = [2,3,4,5] 


removeSmallest([5,3,2,1,4]) = [5,3,2,4] 


removeSmallest([2,2,1,2,1]) = [2,2,2,1]



간단하게 배열 함수들을 사용해서 구현이 가능합니다. 

코드를 한번 보시고 생각하시면 쉽게 이해할 수 있을겁니다 ㅎ


이번 문제는 제가 푼 방식이 모범답안과 유사하여 제가 푼 코드만 올려놓겠습니다 ㅎ

728x90
반응형
그리드형