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