Skip to content

Commit 5775803

Browse files
committed
Create README - LeetHub
1 parent 6852446 commit 5775803

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<h2><a href="https://leetcode.com/problems/coupon-code-validator">3934. Coupon Code Validator</a></h2><h3>Easy</h3><hr><p>You are given three arrays of length <code>n</code> that describe the properties of <code>n</code> coupons: <code>code</code>, <code>businessLine</code>, and <code>isActive</code>. The <code>i<sup>th</sup> </code>coupon has:</p>
2+
3+
<ul>
4+
<li><code>code[i]</code>: a <strong>string</strong> representing the coupon identifier.</li>
5+
<li><code>businessLine[i]</code>: a <strong>string</strong> denoting the business category of the coupon.</li>
6+
<li><code>isActive[i]</code>: a <strong>boolean</strong> indicating whether the coupon is currently active.</li>
7+
</ul>
8+
9+
<p>A coupon is considered <strong>valid</strong> if all of the following conditions hold:</p>
10+
11+
<ol>
12+
<li><code>code[i]</code> is non-empty and consists only of alphanumeric characters (a-z, A-Z, 0-9) and underscores (<code>_</code>).</li>
13+
<li><code>businessLine[i]</code> is one of the following four categories: <code>&quot;electronics&quot;</code>, <code>&quot;grocery&quot;</code>, <code>&quot;pharmacy&quot;</code>, <code>&quot;restaurant&quot;</code>.</li>
14+
<li><code>isActive[i]</code> is <strong>true</strong>.</li>
15+
</ol>
16+
17+
<p>Return an array of the <strong>codes</strong> of all valid coupons, <strong>sorted</strong> first by their <strong>businessLine</strong> in the order: <code>&quot;electronics&quot;</code>, <code>&quot;grocery&quot;</code>, <code>&quot;pharmacy&quot;, &quot;restaurant&quot;</code>, and then by <strong>code</strong> in lexicographical (ascending) order within each category.</p>
18+
19+
<p>&nbsp;</p>
20+
<p><strong class="example">Example 1:</strong></p>
21+
22+
<div class="example-block">
23+
<p><strong>Input:</strong> <span class="example-io">code = [&quot;SAVE20&quot;,&quot;&quot;,&quot;PHARMA5&quot;,&quot;SAVE@20&quot;], businessLine = [&quot;restaurant&quot;,&quot;grocery&quot;,&quot;pharmacy&quot;,&quot;restaurant&quot;], isActive = [true,true,true,true]</span></p>
24+
25+
<p><strong>Output:</strong> <span class="example-io">[&quot;PHARMA5&quot;,&quot;SAVE20&quot;]</span></p>
26+
27+
<p><strong>Explanation:</strong></p>
28+
29+
<ul>
30+
<li>First coupon is valid.</li>
31+
<li>Second coupon has empty code (invalid).</li>
32+
<li>Third coupon is valid.</li>
33+
<li>Fourth coupon has special character <code>@</code> (invalid).</li>
34+
</ul>
35+
</div>
36+
37+
<p><strong class="example">Example 2:</strong></p>
38+
39+
<div class="example-block">
40+
<p><strong>Input:</strong> <span class="example-io">code = [&quot;GROCERY15&quot;,&quot;ELECTRONICS_50&quot;,&quot;DISCOUNT10&quot;], businessLine = [&quot;grocery&quot;,&quot;electronics&quot;,&quot;invalid&quot;], isActive = [false,true,true]</span></p>
41+
42+
<p><strong>Output:</strong> <span class="example-io">[&quot;ELECTRONICS_50&quot;]</span></p>
43+
44+
<p><strong>Explanation:</strong></p>
45+
46+
<ul>
47+
<li>First coupon is inactive (invalid).</li>
48+
<li>Second coupon is valid.</li>
49+
<li>Third coupon has invalid business line (invalid).</li>
50+
</ul>
51+
</div>
52+
53+
<p>&nbsp;</p>
54+
<p><strong>Constraints:</strong></p>
55+
56+
<ul>
57+
<li><code>n == code.length == businessLine.length == isActive.length</code></li>
58+
<li><code>1 &lt;= n &lt;= 100</code></li>
59+
<li><code>0 &lt;= code[i].length, businessLine[i].length &lt;= 100</code></li>
60+
<li><code>code[i]</code> and <code>businessLine[i]</code> consist of printable ASCII characters.</li>
61+
<li><code>isActive[i]</code> is either <code>true</code> or <code>false</code>.</li>
62+
</ul>

0 commit comments

Comments
 (0)