본문 바로가기
728x90

전체 글228

Codesignal - extractEachKth Given array of integers, remove each kth element from it. Example For inputArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] and k = 3, the output should be extractEachKth(inputArray, k) = [1, 2, 4, 5, 7, 8, 10]. Input/Output [execution time limit] 20 seconds (swift) [input] array.integer inputArray Guaranteed constraints: 5 ≤ inputArray.length ≤ 15, -20 ≤ inputArray[i] ≤ 20. [input] integer k Guaranteed .. 2021. 5. 3.
Codesignal - evenDigingsOnly Check if all digits of the given integer are even. Example For n = 248622, the output should be evenDigitsOnly(n) = true; For n = 642386, the output should be evenDigitsOnly(n) = false. Input/Output [execution time limit] 20 seconds (swift) [input] integer n Guaranteed constraints: 1 ≤ n ≤ 109. [output] boolean true if all digits of n are even, false otherwise. 풀이 주어지는 숫자의 각 자리수에 해당하는 숫자가 짝수일때만 .. 2021. 5. 3.
Codesignal - digitDegree Let's define digit degree of some positive integer as the number of times we need to replace this number with the sum of its digits until we get to a one digit number. Given an integer, find its digit degree. Example For n = 5, the output should be digitDegree(n) = 0; For n = 100, the output should be digitDegree(n) = 1. 1 + 0 + 0 = 1. For n = 91, the output should be digitDegree(n) = 2. 9 + 1 =.. 2021. 5. 2.
Codesignal - differentSymbolsNaive Given a string, find the number of different characters in it. Example For s = "cabca", the output should be differentSymbolsNaive(s) = 3. There are 3 different characters a, b and c. Input/Output [execution time limit] 20 seconds (swift) [input] string sGuaranteed constraints: 3 ≤ s.length ≤ 1000. A string of lowercase English letters. [output] integer 설명 주어지는 문자열에서 서로다른 문자의 수를 리턴하라 풀이 Set의 중복 .. 2021. 5. 2.
Codesignal - depositProfit You have deposited a specific amount of money into your bank account. Each year your balance increases at the same growth rate. With the assumption that you don't make any additional deposits, find out how long it would take for your balance to pass a specific threshold. Example For deposit = 100, rate = 20, and threshold = 170, the output should be depositProfit(deposit, rate, threshold) = 3. E.. 2021. 5. 2.
Codesignal - commonCharacterCount Given two strings, find the number of common characters between them. Example For s1 = "aabcc" and s2 = "adcaa", the output should be commonCharacterCount(s1, s2) = 3. Strings have 3 common characters - 2 "a"s and 1 "c". 설명 s1과 s2의 문자열을 분석하여 똑같은 문자의 개수를 구한다. 풀이 s1의 "aabcc"에 a가 2개, s2의 "adcaa"에도 a가 3개 => count에 2 s1의 "aabcc"에 c가 2개, s2의 "adcaa"에 c가 한개 => count에 1 총합 2+1 3을 리턴한다. func commonCharac.. 2021. 5. 1.
Codesignal - Circle of Numbers Consider integer numbers from 0 to n - 1 written down along the circle in such a way that the distance between any two neighboring numbers is equal (note that 0 and n - 1 are neighboring, too). Given n and firstNumber, find the number which is written in the radially opposite position to firstNumber. Example For n = 10 and firstNumber = 2, the output should be circleOfNumbers(n, firstNumber) = 7.. 2021. 5. 1.
Codesignal - chessBoardCellColor Given two cells on the standard chess board, determine whether they have the same color or not. Example For cell1 = "A1" and cell2 = "C3", the output should be chessBoardCellColor(cell1, cell2) = true. For cell1 = "A1" and cell2 = "H3", the output should be chessBoardCellColor(cell1, cell2) = false. Input/Output [execution time limit] 20 seconds (swift) [input] string cell1 Guaranteed constraint.. 2021. 5. 1.
Codesignal - checkPalindrome Given the string, check if it is a palindrome. Example. For inputString = "aabaa", the output should be checkPalindrome(inputString) = true; For inputString = "abac", the output should be checkPalindrome(inputString) = false; For inputString = "a", the output should be checkPalindrome(inputString) = true. Input/Output [execution time limit] 20 seconds (swift) [input] string inputStringGuaranteed.. 2021. 5. 1.