Code Signal_练习题_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…
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 bedi…
You found two items in a treasure chest! The first item weighs weight1 and is worth value1, and the second item weighs weight2 and is worth value2. What is the total maximum value of the items you can take with you, assuming that your max weight capa…
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 o…
Given array of integers, find the maximal possible sum of some of its k consecutive elements. Example For inputArray = [2, 3, 5, 1, 6] and k = 2, the output should bearrayMaxConsecutiveSum(inputArray, k) = 8.All possible sums of 2 consecutive element…
Given a string, find the number of different characters in it. Example For s = "cabca", the output should bedifferentSymbolsNaive(s) = 3. There are 3 different characters a, b and c. 我的解答: def differentSymbolsNaive(s): return len(set(s)) 一模一样 膜拜…
Find the leftmost digit that occurs in a given string. Example For inputString = "var_1__Int", the output should befirstDigit(inputString) = '1'; For inputString = "q2q-q", the output should befirstDigit(inputString) = '2'; For inputSt…
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 beextractEachKth(inputArray, k) = [1, 2, 4, 5, 7, 8, 10]. 我的解答: def extractEachKth(inputArray, k): return…
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. Example For inputArray = ["aba", &quo…
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, o…