From 5ca9c036d383d9e321a50fe0a9d29e6f2aa1f88c Mon Sep 17 00:00:00 2001 From: devenperez Date: Sun, 8 Jan 2023 09:52:59 -0500 Subject: [PATCH] Removing legacy question 28 --- 28-implement-strstr/28-implement-strstr.py | 19 ------------- 28-implement-strstr/README.md | 31 ---------------------- 2 files changed, 50 deletions(-) delete mode 100644 28-implement-strstr/28-implement-strstr.py delete mode 100644 28-implement-strstr/README.md diff --git a/28-implement-strstr/28-implement-strstr.py b/28-implement-strstr/28-implement-strstr.py deleted file mode 100644 index cf42492..0000000 --- a/28-implement-strstr/28-implement-strstr.py +++ /dev/null @@ -1,19 +0,0 @@ -class Solution(object): - def strStr(self, haystack, needle): - """ - :type haystack: str - :type needle: str - :rtype: int - """ - # Empty needle edge-case - if needle == "": - return 0 - - index = 0 - while index + len(needle) <= len(haystack): - if haystack[index] == needle[0]: - if haystack[index:index+len(needle)] == needle: - return index - index += 1 - - return -1 \ No newline at end of file diff --git a/28-implement-strstr/README.md b/28-implement-strstr/README.md deleted file mode 100644 index 8691640..0000000 --- a/28-implement-strstr/README.md +++ /dev/null @@ -1,31 +0,0 @@ -

28. Implement strStr()

Easy


Implement strStr().

- -

Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.

- -

Clarification:

- -

What should we return when needle is an empty string? This is a great question to ask during an interview.

- -

For the purpose of this problem, we will return 0 when needle is an empty string. This is consistent to C's strstr() and Java's indexOf().

- -

 

-

Example 1:

- -
Input: haystack = "hello", needle = "ll"
-Output: 2
-
- -

Example 2:

- -
Input: haystack = "aaaaa", needle = "bba"
-Output: -1
-
- -

 

-

Constraints:

- - -
\ No newline at end of file