-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay 62
More file actions
21 lines (16 loc) · 681 Bytes
/
Day 62
File metadata and controls
21 lines (16 loc) · 681 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#3606.coupon-code-validator:-
class Solution:
def validateCoupons(self, code: List[str], businessLine: List[str], isActive: List[bool]) -> List[str]:
valid_lines = ["electronics", "grocery", "pharmacy", "restaurant"]
order = {line: i for i, line in enumerate(valid_lines)}
res = []
for c, b, a in zip(code, businessLine, isActive):
if not a:
continue
if not c or not all(ch.isalnum() or ch == "_" for ch in c):
continue
if b not in order:
continue
res.append((order[b], c))
res.sort()
return [c for _, c in res]