{"id":"966d3cf4-ffcb-449a-8fbf-b95e3a11ffb1","name":"Longest Duplicate Substring","description":"Given a string s, \r\nconsider all duplicated substrings: (contiguous) substrings of s that occur 2 or more times. \r\nThe occurrences may overlap.\r\n\r\nReturn any duplicated substring that has the longest possible length. \r\nIf s does not have a duplicated substring, the answer is \"\"","inputFormat":"A string S.","outputFormat":"Print a string which is longest duplicate substring (any).\r\nIf no duplicate substring is found just print \"\" (Without quotes)","constraints":"2 <= s.length <= 3 * 10^4\r\ns consists of lowercase English letters","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n // Write Code here\r\n scn.close();\r\n }\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"hard","sampleInput":"banana","sampleOutput":"ana","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"a2073e25-96a1-4875-b400-f40bbe2edd95","name":"Text Processing For Experts","slug":"text-processing-for-experts-859","type":0},{"id":"250721e3-8d64-4136-a15b-de0b2e52bd1f","name":"Longest Duplicate Substring","slug":"longest-duplicate-substring","type":1}],"next":{"id":"adf48575-67c0-4be1-a34a-54f80390f0a1","name":"Longest Prefix Suffix","type":1,"slug":"longest-prefix-suffix"},"prev":{"id":"3eb9e717-a2f9-4e6d-9409-4f09109f9c26","name":"Good Substrings","type":1,"slug":"good-substrings"}}}

Longest Duplicate Substring

Given a string s, consider all duplicated substrings: (contiguous) substrings of s that occur 2 or more times. The occurrences may overlap. Return any duplicated substring that has the longest possible length. If s does not have a duplicated substring, the answer is ""

{"id":"966d3cf4-ffcb-449a-8fbf-b95e3a11ffb1","name":"Longest Duplicate Substring","description":"Given a string s, \r\nconsider all duplicated substrings: (contiguous) substrings of s that occur 2 or more times. \r\nThe occurrences may overlap.\r\n\r\nReturn any duplicated substring that has the longest possible length. \r\nIf s does not have a duplicated substring, the answer is \"\"","inputFormat":"A string S.","outputFormat":"Print a string which is longest duplicate substring (any).\r\nIf no duplicate substring is found just print \"\" (Without quotes)","constraints":"2 <= s.length <= 3 * 10^4\r\ns consists of lowercase English letters","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n // Write Code here\r\n scn.close();\r\n }\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"hard","sampleInput":"banana","sampleOutput":"ana","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"a2073e25-96a1-4875-b400-f40bbe2edd95","name":"Text Processing For Experts","slug":"text-processing-for-experts-859","type":0},{"id":"250721e3-8d64-4136-a15b-de0b2e52bd1f","name":"Longest Duplicate Substring","slug":"longest-duplicate-substring","type":1}],"next":{"id":"adf48575-67c0-4be1-a34a-54f80390f0a1","name":"Longest Prefix Suffix","type":1,"slug":"longest-prefix-suffix"},"prev":{"id":"3eb9e717-a2f9-4e6d-9409-4f09109f9c26","name":"Good Substrings","type":1,"slug":"good-substrings"}}}
plane

Editor


Loading...

Longest Duplicate Substring

hard

Given a string s, consider all duplicated substrings: (contiguous) substrings of s that occur 2 or more times. The occurrences may overlap. Return any duplicated substring that has the longest possible length. If s does not have a duplicated substring, the answer is ""

Constraints

2 <= s.length <= 3 * 10^4 s consists of lowercase English letters

Format

Input

A string S.

Output

Print a string which is longest duplicate substring (any). If no duplicate substring is found just print "" (Without quotes)

Example

Sample Input

banana

Sample Output

ana

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode