Run #1906c4f0

completed

Score

100% (4/4)

Runtime

4μs

vs Previous

No change vs parent

Tied for best

Same as parent

Solution Lineage

Current100%Same as parent
a881520b100%Same as parent
ff533f20100%Improved from parent
c07852e925%Regression from parent
6c4e319f100%Same as parent
0139cffd100%Same as parent
5fd7278e100%Same as parent
2fac06cd100%First in chain

Code

def solve(input):
    if not input:
        return []
    
    result = [0] * len(input)
    result[0] = input[0]
    
    for i in range(1, len(input)):
        result[i] = input[i] - input[i - 1]
    
    return result

Compare with Champion

Score Difference

Tied

Runtime Advantage

2μs slower

Code Size

11 vs 9 lines

#Your Solution#Champion
1def solve(input):1def solve(input):
2 if not input:2 if not input:
3 return []3 return []
4 4 result = [input[0]]
5 result = [0] * len(input)5 previous = input[0]
6 result[0] = input[0]6 for current in input[1:]:
7 7 result.append(current - previous)
8 for i in range(1, len(input)):8 previous = current
9 result[i] = input[i] - input[i - 1]9 return result
10 10
11 return result11
Your Solution
100% (4/4)4μs
1def solve(input):
2 if not input:
3 return []
4
5 result = [0] * len(input)
6 result[0] = input[0]
7
8 for i in range(1, len(input)):
9 result[i] = input[i] - input[i - 1]
10
11 return result
Champion
100% (4/4)2μs
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 = current
9 return result