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
4mo
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...
RUBRIK INDIA Software Developer Intern interview questions & answers
A Software Developer Intern was asked Q. Minimum Removals Problem Statement Given an integer array ARR of size N and an i...read more
A Software Developer Intern was asked Q. Minimum Number of Stabs to Kill the King You are given the initial health of a k...read more
A Software Developer Intern was asked Q. Scramble String Problem Statement You are given an integer 'N' and two strings S...read more
Popular interview questions of Software Developer Intern
A Software Developer Intern was asked Q1. Minimum Removals Problem Statement Given an integer array ARR of size N and an i...read more
A Software Developer Intern was asked Q2. Minimum Number of Stabs to Kill the King You are given the initial health of a k...read more
A Software Developer Intern was asked Q3. Scramble String Problem Statement You are given an integer 'N' and two strings S...read more
>
RUBRIK INDIA Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

