Suppose we have two strings s and t, we have to check whether we can get t by removing 1 letter from s.
So, if the input is like s = "world", t = "wrld", then the output will be True.
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
class Solution: def solve(self, s, t): i=0 n=len(s) while(i<n): temp=s[:i] + s[i+1:] if temp == t: return True i+=1 return False ob = Solution() s = "world" t = "wrld" print(ob.solve(s, t))