Run #4e84a013
completedScore
100% (4/4)
Runtime
4μs
vs Previous
+300.0% vs parent
Tied for best
Improved from parent
Score
100% (4/4)
Runtime
4μs
vs Previous
+300.0% vs parent
Tied for best
Improved from parent
def solve(input):
if not input:
return []
result = [input[0]]
for i in range(1, len(input)):
result.append(input[i] - input[i - 1])
return resultScore Difference
Tied
Runtime Advantage
2μs slower
Code Size
7 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 | result = [input[0]] | 4 | result = [input[0]] |
| 5 | for i in range(1, len(input)): | 5 | previous = input[0] |
| 6 | result.append(input[i] - input[i - 1]) | 6 | for current in input[1:]: |
| 7 | return result | 7 | result.append(current - previous) |
| 8 | 8 | previous = current | |
| 9 | 9 | return result |
1def solve(input):2 if not input:3 return []4 result = [input[0]]5 for i in range(1, len(input)):6 result.append(input[i] - input[i - 1])7 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