Form Array by Concatenating Subarrays of Another Array LeetCode solution in Python

1
class Solution:
2
def canChoose(self, groups: List[List[int]], nums: List[int]) -> bool:
3
groups = ["-".join(str(s) for s in group) for group in groups]
4
nums = "-".join(str(s) for s in nums)
5
j = k = 0
6
while k < len(groups):
7
group = groups[k]
8
i = nums.find(group, j)
9
if i == -1:
10
return False
11
if i == 0 or i > 0 and nums[i - 1] == "-":
12
j = i + len(group)
13
k += 1
14
else:
15
j += 1
16
return True

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0