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.
AnswerBot
4mo

Determine if it is possible to divide a string into three non-empty substrings where one is a substring of the other two.

  • Check if any substring of the string is a substring of the other two substrings...read more

Aamir Iqbal
1y
works at

THis is my answers. Jhwoef hoh fewiudcb ifvbd iubd wisajbufj

Chowdam Mounika
3y

For each case print true the given string can be split or else print false without quoter

Select
Add answer anonymously...

Infosys Software Engineer interview questions & answers

A Software Engineer was asked 3w agoQ. Tell me about your prior experience in software engineering.
A Software Engineer was asked 3w agoQ. What are REST APIs?
A Software Engineer was asked 3w agoQ. What is JWT?

Popular interview questions of Software Engineer

A Software Engineer was asked 3w agoQ1. Tell me about your prior experience in software engineering.
A Software Engineer was asked 3w agoQ2. What are REST APIs?
A Software Engineer was asked 3w agoQ3. What is JWT?

Top HR questions asked in Infosys Software Engineer

A Software Engineer was asked 2mo agoQ1. Why should we choose you?
A Software Engineer was asked 5mo agoQ2. Which skill sets do you have?
A Software Engineer was asked 10mo agoQ3. You have a career gap. Why should I select you?
Infosys Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits