본문 바로가기

Algorithm

(239)
Aracade Intro #38 growingPlant. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Aracade Intro #38 growingPlant. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Q. Each day a plant is growing by upSpeed meters. Each night that plant's height decreases by downSpeed meters due to the lack of sun heat. Initially, plant is 0 meters tall. We plant the seed at the beginning of a day. We want to know when the height of the plant will reach a c..
Aracade Intro #37 arrayMaxConsecutiveSum. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Aracade Intro #37 arrayMaxConsecutiveSum. Algorithm, 알고리즘, Codefights, CodeSignal, 코드파이트, 코드시그널, 예제, example, c++ java c# scalar Q. Given array of integers, find the maximal possible sum of some of its k consecutive elements. 주어진 정수에서 길이값 k 의 수만큼 연속된 길이의 내용물들의 합 최대값을 구하여라 e.g. Input -> inputArray = [2, 3, 5, 1, 6] and k = 2 Output -> arrayMaxConsecutiveSum(inputArray, k) = 8 All possible sums of..
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 ..