题目描述
Given two strings X and Y, the task is to find the last index in X at which string Y appears, if Y does not appear then the answer is -1.
Example 1:
Input: X = "geeksforgeeks", Y = "geeks"
output: 9
Explanation: string "geeks" appears at
index 1 and 9
Example 2:
Input: X = "geesforgees", Y = "geeks"
output: -1
Explanation: "geeks" does not appear
Your task:
You do not need to read any input or print anything. The task is to complete the function search(), which takes two strings as input and returns an integer.
Expected Time Complexity: O(|X| + |Y|)
Expected Auxiliary Space: O(|X| + |Y|)
Constraints:
1 ≤ |X|, |Y| ≤ 10^{5}
Both the strings contains lower case English alphabets
输入格式
见题面
输出格式
见题面