Skip to content

Commit 394c562

Browse files
committed
Create README - LeetHub
1 parent 4e643ef commit 394c562

File tree

1 file changed

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

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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><div><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>""</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><strong>Input:</strong> arr = ["d","b","c","b","c","a"], k = 2
11+
<strong>Output:</strong> "a"
12+
<strong>Explanation:</strong>
13+
The only distinct strings in arr are "d" and "a".
14+
"d" appears 1<sup>st</sup>, so it is the 1<sup>st</sup> distinct string.
15+
"a" appears 2<sup>nd</sup>, so it is the 2<sup>nd</sup> distinct string.
16+
Since k == 2, "a" is returned.
17+
</pre>
18+
19+
<p><strong class="example">Example 2:</strong></p>
20+
21+
<pre><strong>Input:</strong> arr = ["aaa","aa","a"], k = 1
22+
<strong>Output:</strong> "aaa"
23+
<strong>Explanation:</strong>
24+
All strings in arr are distinct, so the 1<sup>st</sup> string "aaa" is returned.
25+
</pre>
26+
27+
<p><strong class="example">Example 3:</strong></p>
28+
29+
<pre><strong>Input:</strong> arr = ["a","b","a"], k = 3
30+
<strong>Output:</strong> ""
31+
<strong>Explanation:</strong>
32+
The only distinct string is "b". Since there are fewer than 3 distinct strings, we return an empty string "".
33+
</pre>
34+
35+
<p>&nbsp;</p>
36+
<p><strong>Constraints:</strong></p>
37+
38+
<ul>
39+
<li><code>1 &lt;= k &lt;= arr.length &lt;= 1000</code></li>
40+
<li><code>1 &lt;= arr[i].length &lt;= 5</code></li>
41+
<li><code>arr[i]</code> consists of lowercase English letters.</li>
42+
</ul>
43+
</div>

0 commit comments

Comments
 (0)