Run #3933d6fd
completedScore
100% (4/4)
Runtime
16μs
vs Previous
No change vs parent
Tied for best
Same as parent
Score
100% (4/4)
Runtime
16μs
vs Previous
No change vs parent
Tied for best
Same as parent
import array
def solve(input):
if not input:
return []
# Direct C-array operation using generator expression in map for performance
it = iter(input)
first = next(it)
return array.array('i', [first] + list(map(lambda x: x[1] - x[0], zip(input, it)))).tolist()Score Difference
Tied
Runtime Advantage
14μs slower
Code Size
10 vs 9 lines
| # | Your Solution | # | Champion |
|---|---|---|---|
| 1 | import array | 1 | def solve(input): |
| 2 | 2 | if not input: | |
| 3 | def solve(input): | 3 | return [] |
| 4 | if not input: | 4 | result = [input[0]] |
| 5 | return [] | 5 | previous = input[0] |
| 6 | 6 | for current in input[1:]: | |
| 7 | # Direct C-array operation using generator expression in map for performance | 7 | result.append(current - previous) |
| 8 | it = iter(input) | 8 | previous = current |
| 9 | first = next(it) | 9 | return result |
| 10 | return array.array('i', [first] + list(map(lambda x: x[1] - x[0], zip(input, it)))).tolist() | 10 |
1import array23def solve(input):4 if not input:5 return []6 7 # Direct C-array operation using generator expression in map for performance8 it = iter(input)9 first = next(it)10 return array.array('i', [first] + list(map(lambda x: x[1] - x[0], zip(input, it)))).tolist()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