Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c6f5401

Browse files
committed
Added README.md file for DI String Match
1 parent a4c056a commit c6f5401

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎979-di-string-match/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<h2><a href="https://leetcode.com/problems/di-string-match">DI String Match</a></h2> <img src='https://img.shields.io/badge/Difficulty-Easy-brightgreen' alt='Difficulty: Easy' /><hr><p>A permutation <code>perm</code> of <code>n + 1</code> integers of all the integers in the range <code>[0, n]</code> can be represented as a string <code>s</code> of length <code>n</code> where:</p>
2+
3+
<ul>
4+
<li><code>s[i] == &#39;I&#39;</code> if <code>perm[i] &lt; perm[i + 1]</code>, and</li>
5+
<li><code>s[i] == &#39;D&#39;</code> if <code>perm[i] &gt; perm[i + 1]</code>.</li>
6+
</ul>
7+
8+
<p>Given a string <code>s</code>, reconstruct the permutation <code>perm</code> and return it. If there are multiple valid permutations perm, return <strong>any of them</strong>.</p>
9+
10+
<p>&nbsp;</p>
11+
<p><strong class="example">Example 1:</strong></p>
12+
<pre><strong>Input:</strong> s = "IDID"
13+
<strong>Output:</strong> [0,4,1,3,2]
14+
</pre><p><strong class="example">Example 2:</strong></p>
15+
<pre><strong>Input:</strong> s = "III"
16+
<strong>Output:</strong> [0,1,2,3]
17+
</pre><p><strong class="example">Example 3:</strong></p>
18+
<pre><strong>Input:</strong> s = "DDI"
19+
<strong>Output:</strong> [3,2,0,1]
20+
</pre>
21+
<p>&nbsp;</p>
22+
<p><strong>Constraints:</strong></p>
23+
24+
<ul>
25+
<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
26+
<li><code>s[i]</code> is either <code>&#39;I&#39;</code> or <code>&#39;D&#39;</code>.</li>
27+
</ul>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /