Split the String Problem Statement
You are given a string str
consisting of N
lowercase alphabets. Your task is to determine if it is possible to divide the string into three non-empty substrings such that one of them is a substring of the other two substrings.
Example:
Input:
str = 'abcabab'
Output:
true
Explanation:
We can split the string into three parts a = 'abc'
, b = 'ab'
, and c = 'abc'
, where b
is a substring of both a
and c
.
Constraints:
1 <= T <= 5
1 <= N <= 10^5
Note:
A substring is a contiguous sequence of characters within a string. For example, 'ab', 'b', and 'abc' are substrings of the string 'abc', but 'ac' is not a substring of 'abc'. A non-empty substring means a substring with a size greater than 0.
Function Implementation:
You do not need to print anything; it has already been taken care of. Just implement the given function and return the answer.
Input:
The first line of input contains an integer 'T' representing the number of test cases. Each test case includes a single integer 'N' indicating the size of the string, followed by the string 'str' of size 'N'.
Output:
For each test case, return "true" if the split is possible, or "false" otherwise.
Be the first one to answer
Add answer anonymously...
Top Mts1 Interview Questions Asked at Nutanix
Q. What are effective paging techniques, and how do you count page faults?
Q. Ninja and Stack of Boxes Problem Help Ninja to create the tallest stack possible...read more
Q. Reverse Edges Problem Statement You are given a directed graph with ‘N’ nodes an...read more
Interview Questions Asked to Mts1 at Other Companies
Top Skill-Based Questions for Nutanix Mts1
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Operating Systems Interview Questions and Answers
250 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

