You are given three arrays of length
nthat describe the properties ofncoupons:code,businessLine, andisActive. Theithcoupon has:
code[i]: a string representing the coupon identifier.businessLine[i]: a string denoting the business category of the coupon.isActive[i]: a boolean indicating whether the coupon is currently active.A coupon is considered valid if all of the following conditions hold:
code[i]is non-empty and consists only of alphanumeric characters (a-z, A-Z, 0-9) and underscores (_).businessLine[i]is one of the following four categories:"electronics","grocery","pharmacy","restaurant".isActive[i]is true.Return an array of the codes of all valid coupons, sorted first by their businessLine in the order:
"electronics","grocery","pharmacy", "restaurant", and then by code in lexicographical (ascending) order within each category.
1 | class Solution { |