easy
strings
two-pointers
Problem
You are given a string s and a substring sub. Your task is to find the index of the first occurrence of sub in s. If sub is not a substring of s, return -1.
Examples
Example 1
Input: s = "hello world", sub = "l"
Output: 2
Example 2
Input: s = "abcdefg", sub = "x"
Output: -1
Example 3
Input: s = "mississippi", sub = "iss"
Output: 1
Running will execute all 3 cases.