class Solution { public: int findTime(string S1, string S2) { // code here int n=S1.size(); int m=S2.size(); unordered_map<char,int>mp; for(int i=0;i<n;i++) { mp[S1[i]]=i; } int ans=0; int temp=0; for(int j=0;j<m;j++) { int b=mp[S2[j]]; ans+=abs(b-temp); temp=b; } return ans; } };