Run #6c4e319f
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):
n = len(input)
if not n:
return []
result = [0] * n
prev = input[0]
result[0] = prev
for i in range(1, n):
curr = input[i]
result[i] = curr - prev
prev = curr
return resultScore Difference
Tied
Runtime Advantage
4μ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 not n: | 3 | return [] |
| 4 | return [] | 4 | result = [input[0]] |
| 5 | 5 | previous = input[0] | |
| 6 | result = [0] * n | 6 | for current in input[1:]: |
| 7 | prev = input[0] | 7 | result.append(current - previous) |
| 8 | result[0] = prev | 8 | previous = current |
| 9 | 9 | return result | |
| 10 | for i in range(1, n): | 10 | |
| 11 | curr = input[i] | 11 | |
| 12 | result[i] = curr - prev | 12 | |
| 13 | prev = curr | 13 | |
| 14 | 14 | ||
| 15 | return result | 15 |
1def solve(input):2 n = len(input)3 if not n:4 return []5 6 result = [0] * n7 prev = input[0]8 result[0] = prev9 10 for i in range(1, n):11 curr = input[i]12 result[i] = curr - prev13 prev = curr1415 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