First Substring Match
Substring search is a basic operation when checking messages, logs, and commands. Given strings haystack and needle, find the index where needle first appears inside haystack. If the substring is not found, return -1.
Примеры
Ввод
"sadbutsad", "sad"Вывод
0Ввод
"leetcode", "leeto"Вывод
-1Ввод
"hello", "ll"Вывод
2Нужно реализовать
def str_str(haystack: str, needle: str) -> int:
Теги
stringstwo-pointers
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
EntrarVisible tests
1
Input
"sadbutsad", "sad"Expected
02
Input
"leetcode", "leeto"Expected
-13
Input
"hello", "ll"Expected
24
Input
"abc", ""Expected
05
Input
"a", "a"Expected
06
Input
"Hello, World!", "sad"Expected
-1Focus radio
Paused · SomaFM · Fluid