Skip to content

Commit cb648a1

Browse files
committed
Create README - LeetHub
1 parent 0724840 commit cb648a1

File tree

1 file changed

+45
-0
lines changed
  • 2053-kth-distinct-string-in-an-array

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<h2><a href="https://leetcode.com/problems/kth-distinct-string-in-an-array">2053. Kth Distinct String in an Array</a></h2><h3>Easy</h3><hr><p>A <strong>distinct string</strong> is a string that is present only <strong>once</strong> in an array.</p>
2+
3+
<p>Given an array of strings <code>arr</code>, and an integer <code>k</code>, return <em>the </em><code>k<sup>th</sup></code><em> <strong>distinct string</strong> present in </em><code>arr</code>. If there are <strong>fewer</strong> than <code>k</code> distinct strings, return <em>an <strong>empty string </strong></em><code>&quot;&quot;</code>.</p>
4+
5+
<p>Note that the strings are considered in the <strong>order in which they appear</strong> in the array.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
10+
<pre>
11+
<strong>Input:</strong> arr = [&quot;d&quot;,&quot;b&quot;,&quot;c&quot;,&quot;b&quot;,&quot;c&quot;,&quot;a&quot;], k = 2
12+
<strong>Output:</strong> &quot;a&quot;
13+
<strong>Explanation:</strong>
14+
The only distinct strings in arr are &quot;d&quot; and &quot;a&quot;.
15+
&quot;d&quot; appears 1<sup>st</sup>, so it is the 1<sup>st</sup> distinct string.
16+
&quot;a&quot; appears 2<sup>nd</sup>, so it is the 2<sup>nd</sup> distinct string.
17+
Since k == 2, &quot;a&quot; is returned.
18+
</pre>
19+
20+
<p><strong class="example">Example 2:</strong></p>
21+
22+
<pre>
23+
<strong>Input:</strong> arr = [&quot;aaa&quot;,&quot;aa&quot;,&quot;a&quot;], k = 1
24+
<strong>Output:</strong> &quot;aaa&quot;
25+
<strong>Explanation:</strong>
26+
All strings in arr are distinct, so the 1<sup>st</sup> string &quot;aaa&quot; is returned.
27+
</pre>
28+
29+
<p><strong class="example">Example 3:</strong></p>
30+
31+
<pre>
32+
<strong>Input:</strong> arr = [&quot;a&quot;,&quot;b&quot;,&quot;a&quot;], k = 3
33+
<strong>Output:</strong> &quot;&quot;
34+
<strong>Explanation:</strong>
35+
The only distinct string is &quot;b&quot;. Since there are fewer than 3 distinct strings, we return an empty string &quot;&quot;.
36+
</pre>
37+
38+
<p>&nbsp;</p>
39+
<p><strong>Constraints:</strong></p>
40+
41+
<ul>
42+
<li><code>1 &lt;= k &lt;= arr.length &lt;= 1000</code></li>
43+
<li><code>1 &lt;= arr[i].length &lt;= 5</code></li>
44+
<li><code>arr[i]</code> consists of lowercase English letters.</li>
45+
</ul>

0 commit comments

Comments
 (0)