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
4mo
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...
Jaguar Land Rover Software Developer interview questions & answers
A Software Developer was asked Q. SELL ABD BUY 1 array question(easy level)
A Software Developer was asked Q. Beautiful String Verification Given a non-empty string inputString, determine if...read more
A Software Developer was asked Q. K Centers Selection Problem In Ninja Land, there are cities numbered from 0 to N...read more
Popular interview questions of Software Developer
A Software Developer was asked Q1. SELL ABD BUY 1 array question(easy level)
A Software Developer was asked Q2. Beautiful String Verification Given a non-empty string inputString, determine if...read more
A Software Developer was asked Q3. K Centers Selection Problem In Ninja Land, there are cities numbered from 0 to N...read more
>
Jaguar Land Rover Software Developer 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

