Run #0d24334d
completedScore
100% (4/4)
Runtime
5μs
vs Previous
No change vs parent
Tied for best
Same as parent
Score
100% (4/4)
Runtime
5μs
vs Previous
No change vs parent
Tied for best
Same as parent
def solve(input):
if not input:
return []
n = len(input)
deltas = [0] * n
deltas[0] = input[0]
for i in range(1, n):
deltas[i] = input[i] - input[i - 1]
return deltasScore Difference
Tied
Runtime Advantage
3μs slower
Code Size
12 vs 9 lines
| # | Your Solution | # | Champion |
|---|---|---|---|
| 1 | def solve(input): | 1 | def solve(input): |
| 2 | if not input: | 2 | if not input: |
| 3 | return [] | 3 | return [] |
| 4 | 4 | result = [input[0]] | |
| 5 | n = len(input) | 5 | previous = input[0] |
| 6 | deltas = [0] * n | 6 | for current in input[1:]: |
| 7 | deltas[0] = input[0] | 7 | result.append(current - previous) |
| 8 | 8 | previous = current | |
| 9 | for i in range(1, n): | 9 | return result |
| 10 | deltas[i] = input[i] - input[i - 1] | 10 | |
| 11 | 11 | ||
| 12 | return deltas | 12 |
1def solve(input):2 if not input:3 return []4 5 n = len(input)6 deltas = [0] * n7 deltas[0] = input[0]8 9 for i in range(1, n):10 deltas[i] = input[i] - input[i - 1]11 12 return deltas1def 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