Skip to content

Commit a6ef630

Browse files
committed
feat: add solutions to lc problems
* No.0028.Find the Index of the First Occurrence in a String * No.0484.Find Permutation
1 parent ef4e652 commit a6ef630

File tree

23 files changed

+839
-334
lines changed

23 files changed

+839
-334
lines changed

solution/0000-0099/0028.Implement strStr()/README.md renamed to solution/0000-0099/0028.Find the Index of the First Occurrence in a String/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# [28. 实现 strStr()](https://leetcode.cn/problems/implement-strstr)
1+
# [28. 实现 strStr()](https://leetcode.cn/problems/find-the-index-of-the-first-occurrence-in-a-string)
22

3-
[English Version](/solution/0000-0099/0028.Implement%20strStr%28%29/README_EN.md)
3+
[English Version](/solution/0000-0099/0028.Find%20the%20Index%20of%20the%20First%20Occurrence%20in%20a%20String/README_EN.md)
44

55
## 题目描述
66

@@ -41,6 +41,7 @@
4141
<li><code>haystack</code> 和 <code>needle</code> 仅由小写英文字符组成</li>
4242
</ul>
4343

44+
4445
## 解法
4546

4647
<!-- 这里可写通用的实现逻辑 -->

solution/0000-0099/0028.Implement strStr()/README_EN.md renamed to solution/0000-0099/0028.Find the Index of the First Occurrence in a String/README_EN.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
1-
# [28. Implement strStr()](https://leetcode.com/problems/implement-strstr)
1+
# [28. Find the Index of the First Occurrence in a String](https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string)
22

3-
[中文文档](/solution/0000-0099/0028.Implement%20strStr%28%29/README.md)
3+
[中文文档](/solution/0000-0099/0028.Find%20the%20Index%20of%20the%20First%20Occurrence%20in%20a%20String/README.md)
44

55
## Description
66

7-
<p>Implement <a href="http://www.cplusplus.com/reference/cstring/strstr/" target="_blank">strStr()</a>.</p>
8-
97
<p>Given two strings <code>needle</code> and <code>haystack</code>, return the index of the first occurrence of <code>needle</code> in <code>haystack</code>, or <code>-1</code> if <code>needle</code> is not part of <code>haystack</code>.</p>
108

11-
<p><strong>Clarification:</strong></p>
12-
13-
<p>What should we return when <code>needle</code> is an empty string? This is a great question to ask during an interview.</p>
14-
15-
<p>For the purpose of this problem, we will return 0 when <code>needle</code> is an empty string. This is consistent to C&#39;s <a href="http://www.cplusplus.com/reference/cstring/strstr/" target="_blank">strstr()</a> and Java&#39;s <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#indexOf(java.lang.String)" target="_blank">indexOf()</a>.</p>
16-
179
<p>&nbsp;</p>
18-
<p><strong>Example 1:</strong></p>
10+
<p><strong class="example">Example 1:</strong></p>
1911

2012
<pre>
21-
<strong>Input:</strong> haystack = &quot;hello&quot;, needle = &quot;ll&quot;
22-
<strong>Output:</strong> 2
13+
<strong>Input:</strong> haystack = &quot;sadbutsad&quot;, needle = &quot;sad&quot;
14+
<strong>Output:</strong> 0
15+
<strong>Explanation:</strong> &quot;sad&quot; occurs at index 0 and 6.
16+
The first occurrence is at index 0, so we return 0.
2317
</pre>
2418

25-
<p><strong>Example 2:</strong></p>
19+
<p><strong class="example">Example 2:</strong></p>
2620

2721
<pre>
28-
<strong>Input:</strong> haystack = &quot;aaaaa&quot;, needle = &quot;bba&quot;
22+
<strong>Input:</strong> haystack = &quot;leetcode&quot;, needle = &quot;leeto&quot;
2923
<strong>Output:</strong> -1
24+
<strong>Explanation:</strong> &quot;leeto&quot; did not occur in &quot;leetcode&quot;, so we return -1.
3025
</pre>
3126

3227
<p>&nbsp;</p>
@@ -37,6 +32,7 @@
3732
<li><code>haystack</code> and <code>needle</code> consist of only lowercase English characters.</li>
3833
</ul>
3934

35+
4036
## Solutions
4137

4238
<!-- tabs:start -->

0 commit comments

Comments
 (0)