String 12: Implement strstr() | Must Do Coding Questions | GeeksForGeeks

Опубликовано: 18 Июнь 2026
на канале: Krishna Teaches
6,561
122

This video contains Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe, …
from geeksforgeeks platform.

website link:
https://www.geeksforgeeks.org/must-do...

Topics covered in this video series are:
1.Arrays
   • 1.1 ARRAYS | Must Do Coding Questions  
2.String
   • 1.2 STRING | Must Do Coding Questions  
3.Linked List
4.Stack and Queue
5.Tree and BST
6.Heap
7.Recursion
8.Hashing
9.Graph
10.Greedy
11.Dynamic Programming
12.Divide and Conquer
13.Backtracking
14.Bit Magic

String:
12. Implement strstr:
Your task is to implement the function strstr. The function takes two strings as arguments (s,x) and locates the occurrence of the string x in the string s. The function returns and integer denoting the first occurrence of the string x in s (0 based indexing).

Example 1:
Input:
s = GeeksForGeeks, x = Fr
Output: -1
Explanation: Fr is not present in the
string GeeksForGeeks as substring.

Example 2:
Input:
s = GeeksForGeeks, x = For
Output: 5
Explanation: For is present as substring
in GeeksForGeeks from index 5 (0 based
indexing).

Code Link:
https://github.com/krishna-gavas/Comp...

Intro Music :
   • Video  p