Run #3a42fee5
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):
n = len(input)
if n == 0:
return []
deltas = [0] * n
deltas[0] = input[0]
last_value = input[0]
for i in range(1, n):
current_value = input[i]
deltas[i] = current_value - last_value
last_value = current_value
return deltasScore Difference
Tied
Runtime Advantage
3μs slower
Code Size
15 vs 9 lines
| # | Your Solution | # | Champion |
|---|---|---|---|
| 1 | def solve(input): | 1 | def solve(input): |
| 2 | n = len(input) | 2 | if not input: |
| 3 | if n == 0: | 3 | return [] |
| 4 | return [] | 4 | result = [input[0]] |
| 5 | 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 | last_value = input[0] | 8 | previous = current |
| 9 | 9 | return result | |
| 10 | for i in range(1, n): | 10 | |
| 11 | current_value = input[i] | 11 | |
| 12 | deltas[i] = current_value - last_value | 12 | |
| 13 | last_value = current_value | 13 | |
| 14 | 14 | ||
| 15 | return deltas | 15 |
1def solve(input):2 n = len(input)3 if n == 0:4 return []5 6 deltas = [0] * n7 deltas[0] = input[0]8 last_value = input[0]9 10 for i in range(1, n):11 current_value = input[i]12 deltas[i] = current_value - last_value13 last_value = current_value14 15 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