Problem:
Given a string, output its longest prefix which contains only digits.
Example
For inputString = "123aa1", the output should be
longestDigitsPrefix(inputString) = "123".
-Summary-
1. inputString의 각 캐릭터들을 앞에서부터 차례차례 비교하여 만약에 digit일 경우에는 longestDigits 에 넣어주고 아닐경우에는 바로 break 하여 loop 을 나옴
2. loop을 돌며 저장해온 longestDigits 값 return.
모든 문제에 대한 저작권은 CodeSignal 회사에 있습니다. [Copyright © 2020 BrainFights Inc. All rights reserved]
'CodeSignal > Arcade' 카테고리의 다른 글
CodeSignal [42/60] bishopAndPawn (0) | 2020.05.26 |
---|---|
CodeSignal [41/60] digitDegree (0) | 2020.05.26 |
CodeSignal [39/60] knapsackLight (0) | 2020.05.26 |
CodeSignal [38/60] growingPlant (0) | 2020.05.25 |
CodeSignal [37/60] arrayMaxConsecutiveSum (0) | 2020.05.25 |
댓글