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
andR
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 onS
.
3. Operations can only be applied on the stringS
.
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
8d
Given two strings of the same length, determine if one can be scrambled to obtain the other using specified operations.
Check if the two strings are equal, if so return true.
Check if the characters in ...read more
Help your peers!
Add answer anonymously...
Top RUBRIK INDIA Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
>
RUBRIK INDIA Software Developer Intern Interview Questions
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