Scramble String Problem Statement

You are given an integer 'N' and two strings S and R, each having the size N. Determine if you can scramble string S to obtain string R using specified operations.

Your task is to return true if R is a scrambled string of S, otherwise return false.

Example:

Input:
T = 1
N = 3
S = 'abc', R = 'bca'
Output:
true
Constraints:
  • 1 <= T <= 50
  • 1 <= len(S) <= 30
  • S and R consist of lowercase letters only.

Note:

1. Both strings are non-empty and of the same length.
2. You can apply the operations any number of times on S.
3. Operations can only be applied on the string S.

Input:

The first line of the input contains an integer 'T' denoting the number of test cases.
The first line of each test case contains an integer ‘N’, denoting the size of the strings.
The second line of each test case contains two space-separated strings ‘S’ and ‘R’.

Output:

For each test case, print a single line containing either "true" if the string 'R' is a scrambled string of ‘S’, else "false".
AnswerBot
1y

The question asks to determine if string 'R' can be obtained by scrambling string 'S' using certain operations.

  • The length of both strings 'S' and 'R' should be the same.

  • The operations can be applied r...read more

Help your peers!
Add answer anonymously...
Wunderman Thompson Commerce Technical Associate 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