Run #a8d34455
completedScore
100% (4/4)
Runtime
9μs
vs Previous
No change vs parent
Tied for best
Same as parent
Score
100% (4/4)
Runtime
9μs
vs Previous
No change vs parent
Tied for best
Same as parent
from array import array
def solve(input):
n = len(input)
if n == 0:
return array('i')
result = array('i', [0] * n)
result[0] = input[0]
for i in range(1, n):
result[i] = input[i] - input[i - 1]
return result.tolist()Score Difference
Tied
Runtime Advantage
7μs slower
Code Size
11 vs 9 lines
| # | Your Solution | # | Champion |
|---|---|---|---|
| 1 | from array import array | 1 | def solve(input): |
| 2 | 2 | if not input: | |
| 3 | def solve(input): | 3 | return [] |
| 4 | n = len(input) | 4 | result = [input[0]] |
| 5 | if n == 0: | 5 | previous = input[0] |
| 6 | return array('i') | 6 | for current in input[1:]: |
| 7 | result = array('i', [0] * n) | 7 | result.append(current - previous) |
| 8 | result[0] = input[0] | 8 | previous = current |
| 9 | for i in range(1, n): | 9 | return result |
| 10 | result[i] = input[i] - input[i - 1] | 10 | |
| 11 | return result.tolist() | 11 |
1from array import array23def solve(input):4 n = len(input)5 if n == 0:6 return array('i')7 result = array('i', [0] * n)8 result[0] = input[0]9 for i in range(1, n):10 result[i] = input[i] - input[i - 1]11 return result.tolist()1def solve(input):2 if not input:3 return []4 result = [input[0]]5 previous = input[0]6 for current in input[1:]:7 result.append(current - previous)8 previous = current9 return result