Code Signal_练习题_All Longest Strings】的更多相关文章

Given an array of strings, return another array containing all of its longest strings. Example For inputArray = ["aba", "aa", "ad", "vcd", "aba"], the output should beallLongestStrings(inputArray) = ["…
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…
You have a string s that consists of English letters, punctuation marks, whitespace characters, and brackets. It is guaranteed that the parentheses in s form a regular bracket sequence. Your task is to reverse the strings contained in each pair of ma…
Given two strings, find the number of common characters between them. Example For s1 = "aabcc" and s2 = "adcaa", the output should becommonCharacterCount(s1, s2) = 3. Strings have 3 common characters - 2 "a"s and 1 "c&qu…
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…