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