![]() |
Given a string s of length n. The task is to determine the longest substring t such that t is neither the prefix nor the suffix of string s, and that substring must appear as both prefix and suffix of the string s. If no such string exists, print -1. Example:
Approach:
Steps-by-step approach:
Below is the implementation of the above approach: C++
Java
Python3
C#
Javascript
Output
fix Time Complexity: O(N) |
Reffered: https://www.geeksforgeeks.org
Competitive Programming |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 16 |