Given two strings, str1 and str2, the task is to print the indices(Consider, indices starting from 0) of occurrence of str2 in str1. If no such index occurs, print “NONE”.
Input : GeeksforGeeks Geeks Output : 0 8 Input : GFG g Output : NONE
A simple solution is to check all substrings of given string one by one. If a substring matches, print its index.
Time Complexity : O(n * n)
An efficient solution is to KMP string matching algorithm.
Rated as one of the most sought after skills in the industry, own the basics of coding with our C++ STL Course and master the very concepts by intense problem-solving.
- Count maximum occurrence of subsequence in string such that indices in subsequence is in A.P.
- Minimize the length of string by removing occurrence of only one character
- Sub-strings that start and end with one character and have at least one other
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string
- Find the starting indices of the substrings in string (S) which is made by concatenating all words from a list(L)
- Queries to insert, delete one occurrence of a number and print the least and most frequent element
- Rearrange given string to maximize the occurrence of string t
- Ways of transforming one string to other by removing 0 or more characters
- Converting one string to other using append and delete last operations
- Check if characters of one string can be swapped to form other
- Check if max occurring character of one string appears same no. of times in other
- Number of substrings of one string present in other
- Minimum steps to convert one binary string to other only using negation
- Check if one string can be converted to other using given operation
- Find the Nth occurrence of a character in the given String
- Given two numbers as strings, find if one is a power of other
- Print all possible combinations of the string by replacing '$' with any other digit from the string
- Program to count occurrence of a given character in a string
- Generate two output strings depending upon occurrence of character in input string.
- Generate two output strings depending upon occurrence of character in input string in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.