Run #7aa61938
completedScore
100% (4/4)
Runtime
3μs
vs Previous
No change vs parent
Tied for best
Same as parent
Score
100% (4/4)
Runtime
3μs
vs Previous
No change vs parent
Tied for best
Same as parent
def solve(input):
# Edge case: Empty input list
if not input:
return []
# Using list comprehension to create delta encoded list
return [input[i] - input[i - 1] if i > 0 else input[i] for i in range(len(input))]Score Difference
Tied
Runtime Advantage
1μs slower
Code Size
7 vs 9 lines
| # | Your Solution | # | Champion |
|---|---|---|---|
| 1 | def solve(input): | 1 | def solve(input): |
| 2 | # Edge case: Empty input list | 2 | if not input: |
| 3 | if not input: | 3 | return [] |
| 4 | return [] | 4 | result = [input[0]] |
| 5 | 5 | previous = input[0] | |
| 6 | # Using list comprehension to create delta encoded list | 6 | for current in input[1:]: |
| 7 | return [input[i] - input[i - 1] if i > 0 else input[i] for i in range(len(input))] | 7 | result.append(current - previous) |
| 8 | 8 | previous = current | |
| 9 | 9 | return result |
1def solve(input):2 # Edge case: Empty input list3 if not input:4 return []56 # Using list comprehension to create delta encoded list7 return [input[i] - input[i - 1] if i > 0 else input[i] for i in range(len(input))]1def 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