题目描述
Given two strings A and B, you need to find the last occurrence ( 1 based indexing) of string B in string A.
Example 1:
Input:
A = abcdefghijklghifghsd
B = ghi
Output:
13
Explanation:
ghi occurs at position 13 for the
last time in string A.
Example 2:
Input:
A = abdbccaeab
B = abc
Output:
-1
Explanation:
abc is not a substring of A
Your Task:
You don't need to read input or print anything. Your task is to complete the function findLastOccurence() which takes two strings A and B as input parameters and returns the position of the last occurrence of B in A. If B is not present in A, return -1.
Expected Time Complexity: O(len(A))
Expected Space Complexity: O(len(A))
Constarints:
1<=T<=100
1<=len(B)<=10^{5}
1<=len(A)<=10^{6}
len(A)>=len(B)
输入格式
见题面
输出格式
见题面