The maximum substring
Practice
3.3 (10 votes)
Algorithms
String manipulation
Problem
90% Success 1820 Attempts 30 Points 3s Time Limit 256MB Memory 1024 KB Max Code
You are given a string \(s\) consisting only of lowercase letters. A substring \([l;\ r]\) of \(s\) is a string \(s[l...r]\) and its length is equal to \(r-l+1\). Find the substring of \(s\) that contains a maximum number of occurrences.
If several answers exist, then print the one with the maximum length. If there are still several answers, then print the one with the minimum index of the first occurrence.
Input format
The single line contains string \(s\) (\(1 \le |s| \le 10^5\)).
Output format
Find the suitable substring.
Submissions
Please login to view your submissions
Similar Problems
Points:30
7 votes
Tags:
Easy
Points:30
16 votes
Tags:
ApprovedEasyHash MapsKMP AlgorithmOpenString Manipulation
Points:30
22 votes
Tags:
String manipulationString AlgorithmsAlgorithmsString Searching
Editorial