문제: Given an array of integers, replace all the occurrences of elemToReplace with substitutionElem.
Example: For inputArray = [1, 2, 1], elemToReplace = 1, and substitutionElem = 3, the output should be
arrayReplace(inputArray, elemToReplace, substitutionElem) = [3, 2, 3].
요약정리
1. Input Array 의 모든 element 들에 대하여 loop을 돈다.
2. Loop을 돌며, 만약 element 가 elemToReplace 와 값이 같으면, substitutionElem으로 교체해준다.
3. Loop을 마치고 바뀐 Input Array 값을 리턴.
모든 문제에 대한 저작권은 CodeSignal 회사에 있습니다. [Copyright © 2020 BrainFights Inc. All rights reserved]
'CodeSignal > Arcade' 카테고리의 다른 글
CodeSignal [30/60] circleOfNumbers (0) | 2020.05.21 |
---|---|
CodeSignal [29/60] chessBoardCellColor (0) | 2020.05.20 |
CodeSignal [28/60] alphabeticShift (0) | 2020.05.19 |
CodeSignal [27/60] variableName (0) | 2020.05.18 |
CodeSignal [26/60] evenDigitsOnly (0) | 2020.05.17 |
댓글