Run #65ba694b
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):
length = len(input)
if length == 0:
return []
res = [0] * length
res[0] = input[0]
prev = input[0]
for i in range(1, length):
current = input[i]
res[i] = current - prev
prev = current
return resScore 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 | length = len(input) | 2 | if not input: |
| 3 | if length == 0: | 3 | return [] |
| 4 | return [] | 4 | result = [input[0]] |
| 5 | 5 | previous = input[0] | |
| 6 | res = [0] * length | 6 | for current in input[1:]: |
| 7 | res[0] = input[0] | 7 | result.append(current - previous) |
| 8 | prev = input[0] | 8 | previous = current |
| 9 | 9 | return result | |
| 10 | for i in range(1, length): | 10 | |
| 11 | current = input[i] | 11 | |
| 12 | res[i] = current - prev | 12 | |
| 13 | prev = current | 13 | |
| 14 | 14 | ||
| 15 | return res | 15 |
1def solve(input):2 length = len(input)3 if length == 0:4 return []56 res = [0] * length7 res[0] = input[0]8 prev = input[0]910 for i in range(1, length):11 current = input[i]12 res[i] = current - prev13 prev = current1415 return res1def 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