Run #2fac06cd

completed

Score

100% (4/4)

Runtime

4μs

vs Previous

Tied for best

First in chain

Code

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

Compare with Champion

Score Difference

Tied

Runtime Advantage

2μs slower

Code Size

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