Python(27)
-
[Python] CodeSignal 문제 풀이 (7~9)
7. Given a sequence of integers as an array, determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from the array. Note: sequence a0, a1, ..., an is considered to be a strictly increasing if a0 < a1 < ... < an. Sequence containing only one element is also considered to be strictly increasing. [Exam] For sequence = [1, 3, 2, 1], the output ..
2020.02.16 -
[Python] CodeSignal 문제 풀이 (4~6)
4. Given an array of integers, find the pair of adjacent elements that has the largest product and return that product. For inputArray = [3, 6, -2, -5, 7, 3], the output should be adjacentElementsProduct(inputArray) = 21. 7 and 3 produce the largest product. def adjacentElementsProduct(inputArray): return max([inputArray[i] * inputArray[i + 1] for i in range(len(inputArray) - 1)]) 5. Below we wi..
2020.02.16 -
[Python] CodeSignal 문제 풀이 (1~3)
1. Write a function that returns the sum of two numbers. For param1 = 1 and param2 = 2, the output should be add(param1, param2) = 3. def add(param1, param2): return param1 + param2 2. Given a year, return the century it is in. The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc. For year = 1905, the outpu..
2020.02.05