One Away
You are given two strings, string A and string B. Your task is to determine whether string A can be transformed into string B by performing only one of the following operations at most one (or maybe zero) time.
1. You can delete a character from any position.
2. You can replace a character with any other character.
3. You can insert a character at any position.
Note :
1. The strings are non-empty.
2. The strings only contain lowercase English letters.
Input Format :
The first line of the input contains an integer T denoting the number of test cases.
The first line of each test case contains a string A.
The second line of each test case contains a string B.
Output Format :
For each test case print in a new line, “True” if string A can be transformed into string B or “False” if this can’t be done.
Note :
You do not need to print anything, it has already been taken care of. Just implement the given function.
Constraints :
1 <= T <= 100
1 <= |A| <= 10^4
1 <= |B| <= 10^4
Where where |A| represents the size of the string A and where |B| represents the size of the string B.
Time Limit: 1sec
CodingNinjas
author
2y
The idea is to create a new character array and copy the characters from the original String before the given position
After that, we put the new character at the position and copy the rest of the char...read more
CodingNinjas
author
2y
Check Remaining Substrings
- The idea behind this approach is to run a loop through every index of the string A.
- First, we can check the difference between the lengths of the two strings. If this differen...read more
CodingNinjas
author
2y
Using Two Pointers
- The idea behind this approach is to maintain a variable that keeps the count of mismatched characters and one pointer for each string and compare the characters at these places
- First,...read more
Add answer anonymously...
Top PayPal Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Top HR questions asked in PayPal Software Developer Intern
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app