
Beautiful String Verification
Given a non-empty string inputString
, determine if it can be converted into a 'Beautiful String' using the defined operation.
You can perform any number of operations to convert inputString
into a 'Beautiful String'.
Operation:
Insert 'abc' into 'inputString'.
If 'inputString' is empty, simply insert 'abc'.
If 'inputString' is not empty, insert 'abc' at any position such that:
1. 'LEFT PORTION OF inputString' + 'abc' + 'RIGHT PORTION OF inputString' = 'Beautiful String'.
2. 'LEFT PORTION OF inputString' may be EMPTY OR 'a' OR 'ab' OR 'abc'.
3. 'RIGHT PORTION OF inputString' may be EMPTY OR 'c' OR 'bc' OR 'abc'.
Task:
Determine if inputString
is already a 'Beautiful String' or not.
Input:
The first line contains an integer 'T' which denotes the number of test cases.
The following lines for each test case contain a string 'inputString'.
Output:
For each test case, print "True" if the string is a 'Beautiful String', otherwise print "False".
Example:
See the example below:
Input:
2
abcabcabc
abcabc
Output:
True
False
Constraints:
1 <= T <= 100
1 <= |inputString| <= 1000
- The string
inputString
consists only of lowercase alphabets.
Note:
You do not need to handle any I/O operations; just implement the required function logic.

AnswerBot
11d

Determine if a given string can be converted into a 'Beautiful String' using a specific operation.
Check if the input string is already a 'Beautiful String' by checking if it contains 'abc' in the corr...read more

Help your peers!
Add answer anonymously...
Top Jaguar Land Rover Software Developer interview questions & answers
Popular interview questions of Software Developer
>
Jaguar Land Rover Software Developer 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