Coupon Code Validator
pupil · 360 · lc easy +23 · premium · 65% accepted · 333 likes · top 69%
Description
Three arrays code, businessLine, and isActive (each of length n) describe n coupons. The i-th coupon has:
- code[i]: the coupon's identifier string.
- businessLine[i]: the coupon's business category.
- isActive[i]: whether the coupon is currently active.
A coupon is valid when all of the following hold:
- code[i] is non-empty and contains only alphanumeric characters or underscores (_).
- businessLine[i] is exactly one of "electronics", "grocery", "pharmacy", or "restaurant".
- isActive[i] is true.
Return the codes of all valid coupons sorted by businessLine in the order "electronics", "grocery", "pharmacy", "restaurant", then lexicographically within each category.
Code