One Away Transformation Problem

Given two strings, A and B, determine whether A can be transformed into B by performing at most one of the following operations (including zero operations):

1. Delete a character from any position. 2. Replace a character with any other character. 3. Insert a character at any position.

Input:

Input begins with a single integer T, which stands for the number of test cases. Each test case has two lines: the first line is a string A, and the second line is a string B.

Output:

For each test case, output "True" if string A can be transformed into string B, "False" otherwise.

Example:

Input:
T = 1
A = "pale"
B = "ple"
Output:
True

Constraints:

  • 1 ≤ T ≤ 100
  • 1 ≤ |A| ≤ 104
  • 1 ≤ |B| ≤ 104
  • Both strings contain only lowercase English letters.

Note:

You do not need to print anything; it has already been handled. Just implement the function provided.
Be the first one to answer
Add answer anonymously...
PayPal Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter