Question: Problem statement: Given two strings text and pattern find the first occurrence of str1 in str2 if found print its index if not found print
Problem statement: Given two strings text and pattern find the first occurrence of str1 in str2 if found print its index if not found print -1.
Examples:
Example 1: Input: str1 = "takeuforward" str2 = forward Output: 5 Explanation: "Forward" is present in the 5th index in "takeuforward"
Example 2: Input: str1 = hello str2 = az Output: -1 Explanation: "az" is not a substring of "hello"
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
