Describe the Painting LeetCode solution in Python

1
class Solution:
2
def splitPainting(self, segments: List[List[int]]) -> List[List[int]]:
3
mix, res, last_i = DefaultDict(int), [], 0
4
for start, end, color in segments:
5
mix[start] += color
6
mix[end] -= color
7
for i in sorted(mix.keys()):
8
if last_i in mix and mix[last_i]:
9
res.append([last_i, i, mix[last_i]])
10
mix[i] += mix[last_i]
11
last_i = i
12
return res

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0