-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added README.md file for The k-th Lexicographical String of All Happy…
… Strings of Length n
- Loading branch information
1 parent
d635809
commit cbe6e32
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
1516-the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<h2><a href="https://leetcode.com/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n">The k-th Lexicographical String of All Happy Strings of Length n</a></h2> <img src='https://img.shields.io/badge/Difficulty-Medium-orange' alt='Difficulty: Medium' /><hr><p>A <strong>happy string</strong> is a string that:</p> | ||
|
||
<ul> | ||
<li>consists only of letters of the set <code>['a', 'b', 'c']</code>.</li> | ||
<li><code>s[i] != s[i + 1]</code> for all values of <code>i</code> from <code>1</code> to <code>s.length - 1</code> (string is 1-indexed).</li> | ||
</ul> | ||
|
||
<p>For example, strings <strong>"abc", "ac", "b"</strong> and <strong>"abcbabcbcb"</strong> are all happy strings and strings <strong>"aa", "baa"</strong> and <strong>"ababbc"</strong> are not happy strings.</p> | ||
|
||
<p>Given two integers <code>n</code> and <code>k</code>, consider a list of all happy strings of length <code>n</code> sorted in lexicographical order.</p> | ||
|
||
<p>Return <em>the kth string</em> of this list or return an <strong>empty string</strong> if there are less than <code>k</code> happy strings of length <code>n</code>.</p> | ||
|
||
<p> </p> | ||
<p><strong class="example">Example 1:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> n = 1, k = 3 | ||
<strong>Output:</strong> "c" | ||
<strong>Explanation:</strong> The list ["a", "b", "c"] contains all happy strings of length 1. The third string is "c". | ||
</pre> | ||
|
||
<p><strong class="example">Example 2:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> n = 1, k = 4 | ||
<strong>Output:</strong> "" | ||
<strong>Explanation:</strong> There are only 3 happy strings of length 1. | ||
</pre> | ||
|
||
<p><strong class="example">Example 3:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> n = 3, k = 9 | ||
<strong>Output:</strong> "cab" | ||
<strong>Explanation:</strong> There are 12 different happy string of length 3 ["aba", "abc", "aca", "acb", "bab", "bac", "bca", "bcb", "cab", "cac", "cba", "cbc"]. You will find the 9<sup>th</sup> string = "cab" | ||
</pre> | ||
|
||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
|
||
<ul> | ||
<li><code>1 <= n <= 10</code></li> | ||
<li><code>1 <= k <= 100</code></li> | ||
</ul> |