Run #2511b26c
completedScore
100% (4/4)
Runtime
10μs
vs Previous
No change vs parent
Tied for best
Same as parent
Score
100% (4/4)
Runtime
10μs
vs Previous
No change vs parent
Tied for best
Same as parent
from array import array
def solve(input):
if not input:
return []
result = array('i', [0] * len(input))
result[0] = input[0]
for i in range(1, len(input)):
result[i] = input[i] - input[i-1]
return result.tolist()Score Difference
Tied
Runtime Advantage
8μs slower
Code Size
13 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 | if not input: | 4 | result = [input[0]] |
| 5 | return [] | 5 | previous = input[0] |
| 6 | 6 | for current in input[1:]: | |
| 7 | result = array('i', [0] * len(input)) | 7 | result.append(current - previous) |
| 8 | result[0] = input[0] | 8 | previous = current |
| 9 | 9 | return result | |
| 10 | for i in range(1, len(input)): | 10 | |
| 11 | result[i] = input[i] - input[i-1] | 11 | |
| 12 | 12 | ||
| 13 | return result.tolist() | 13 |
1from array import array23def solve(input):4 if not input:5 return []6 7 result = array('i', [0] * len(input))8 result[0] = input[0]9 10 for i in range(1, len(input)):11 result[i] = input[i] - input[i-1]12 13 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