본문 바로가기

Algorithm/Code Fights (Code Signal)

(68)
Aracade Intro #36 differentSymbolsNaive. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Aracade Intro #36 differentSymbolsNaive. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Q. Given a string, find the number of different characters in it. 주어진 string에서, 각자 다른 character 의 개수를 찾아봐라 e.g. Input -> s = "cabca" Output -> differentSymbolsNaive(s) = 3 There are 3 different characters a, b and c. // Process// 1. Input string s// 2. Iterate from begi..
Aracade Intro #35 firstDigit. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Aracade Intro #35 firstDigit. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Q. Find the leftmost digit that occurs in a given string. 입력받은 string 내에서 가장 왼쪽에 있는 숫자를 찾아라 e.g. Input -> inputString = "var_1__Int" Output -> firstDigit(inputString) = '1' Input -> inputString = "q2q-q" Output -> firstDigit(inputString) = '2' Input -> inputString = "0ss" Output -..
Aracade Intro #34 extractEachKth. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Aracade Intro #34 extractEachKth. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Q. Given array of integers, remove each kth element from it. 주어진 정수 배열에서, e.g. Input -> inputArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] and k = 3 Output -> extractEachKth(inputArray, k) = [1, 2, 4, 5, 7, 8, 10]. // Process// 1. Input vector// 2. Iterate from begin to end// 2.1. c..
Aracade Intro #33 stringsRearrangement. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Aracade Intro #33 stringsRearrangement. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Q. Given an array of equal-length strings, check if it is possible to rearrange the strings in such a way that after the rearrangement the strings at consecutive positions would differ by exactly one character. 주어진 같은 길이의 string 배열들에서, 한개의 char 씩만 교체 가능해서 연속적으로 이어지는 자리로 ..
Aracade Intro #32 absoluteValuesSumMinimization. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Aracade Intro #32 absoluteValuesSumMinimization. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Q. Given a sorted array of integers a, find an integer x from a such that the value of abs(a[0] - x) + abs(a[1] - x) + ... + abs(a[a.length - 1] - x) is the smallest possible (here abs denotes the absolute value).If there are several possible answers, output the..
Aracade Intro #31 depositProfit. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Aracade Intro #31 depositProfit. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Q. 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. Of ..
Aracade Intro #30 circleOfNumbers. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Aracade Intro #30 circleOfNumbers. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Q. 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 oppos..
Aracade Intro #29 chessBoardCellColor. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Aracade Intro #29 chessBoardCellColor. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Q. Given two cells on the standard chess board, determine whether they have the same color or not. 체스판에서 주어진 두개의 셀이, 같은 색깔인지 아닌지 확인하라. e.g. For cell1 = "A1" and cell2 = "C3", the output should bechessBoardCellColor(cell1, cell2) = true. For cell1 = "A1" and cell2 = "H3", ..