Skip to content

Commit 541c93e

Browse files
committed
Create README - LeetHub
1 parent 8bff841 commit 541c93e

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<h2><a href="https://leetcode.com/problems/adding-spaces-to-a-string/">2109. Adding Spaces to a String</a></h2><h3>Medium</h3><hr><p>You are given a <strong>0-indexed</strong> string <code>s</code> and a <strong>0-indexed</strong> integer array <code>spaces</code> that describes the indices in the original string where spaces will be added. Each space should be inserted <strong>before</strong> the character at the given index.</p>
2+
3+
<ul>
4+
<li>For example, given <code>s = &quot;EnjoyYourCoffee&quot;</code> and <code>spaces = [5, 9]</code>, we place spaces before <code>&#39;Y&#39;</code> and <code>&#39;C&#39;</code>, which are at indices <code>5</code> and <code>9</code> respectively. Thus, we obtain <code>&quot;Enjoy <strong><u>Y</u></strong>our <u><strong>C</strong></u>offee&quot;</code>.</li>
5+
</ul>
6+
7+
<p>Return<strong> </strong><em>the modified string <strong>after</strong> the spaces have been added.</em></p>
8+
9+
<p>&nbsp;</p>
10+
<p><strong class="example">Example 1:</strong></p>
11+
12+
<pre>
13+
<strong>Input:</strong> s = &quot;LeetcodeHelpsMeLearn&quot;, spaces = [8,13,15]
14+
<strong>Output:</strong> &quot;Leetcode Helps Me Learn&quot;
15+
<strong>Explanation:</strong>
16+
The indices 8, 13, and 15 correspond to the underlined characters in &quot;Leetcode<u><strong>H</strong></u>elps<u><strong>M</strong></u>e<u><strong>L</strong></u>earn&quot;.
17+
We then place spaces before those characters.
18+
</pre>
19+
20+
<p><strong class="example">Example 2:</strong></p>
21+
22+
<pre>
23+
<strong>Input:</strong> s = &quot;icodeinpython&quot;, spaces = [1,5,7,9]
24+
<strong>Output:</strong> &quot;i code in py thon&quot;
25+
<strong>Explanation:</strong>
26+
The indices 1, 5, 7, and 9 correspond to the underlined characters in &quot;i<u><strong>c</strong></u>ode<u><strong>i</strong></u>n<u><strong>p</strong></u>y<u><strong>t</strong></u>hon&quot;.
27+
We then place spaces before those characters.
28+
</pre>
29+
30+
<p><strong class="example">Example 3:</strong></p>
31+
32+
<pre>
33+
<strong>Input:</strong> s = &quot;spacing&quot;, spaces = [0,1,2,3,4,5,6]
34+
<strong>Output:</strong> &quot; s p a c i n g&quot;
35+
<strong>Explanation:</strong>
36+
We are also able to place spaces before the first character of the string.
37+
</pre>
38+
39+
<p>&nbsp;</p>
40+
<p><strong>Constraints:</strong></p>
41+
42+
<ul>
43+
<li><code>1 &lt;= s.length &lt;= 3 * 10<sup>5</sup></code></li>
44+
<li><code>s</code> consists only of lowercase and uppercase English letters.</li>
45+
<li><code>1 &lt;= spaces.length &lt;= 3 * 10<sup>5</sup></code></li>
46+
<li><code>0 &lt;= spaces[i] &lt;= s.length - 1</code></li>
47+
<li>All the values of <code>spaces</code> are <strong>strictly increasing</strong>.</li>
48+
</ul>

0 commit comments

Comments
 (0)