Python/Code_Signal(14)
-
Python #Code_Signal_[Step 4 - 6]
Step 4. Given an array of integers, find the pair of adjacent elements that has the largest product and return that product. My answer: def adjacentElementsProduct(inputArray): a=1 valuearray=[] for i in range(len(inputArray)): a *= inputArray[i] if i>0: valuearray.append(a) a = inputArray[i] return max(valuearray) Best answer: def adjacentElementsProduct(inputArray): return max([inputArray[i] *..
2020.01.08 -
Python #Code_Signal_[Step 1 - 3]
Step 1 Write a function that returns the sum of two numbers. My solution: def add(param1, param2): param1 += param2 return param1 Best solution: def add(param1, param2): return param1 + param2 Step 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. My solution..
2020.01.07