Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

Problem: Nice Strings.

Правка en1, от sam_2912, 2022-06-23 08:56:41

A string of length K is called a nice if the frequency of one of its characters is greater than or equal to floor(K/2). You are given a string s of length N, find the length of longest nice substring.

Input format - First line: T number of test cases. - For each test case first line contains N, i.e., length of string s and next line contains the string s itself.

Output format - For each test case output the length of longest nice substring.

Sample Input 1 5 abcde

Sample Output 3

Constraints - T <= 10 - N <= 10^5

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский sam_2912 2022-06-23 09:19:27 63 Tiny change: 'est cases.\n- For ea' -> 'est cases. \n\n- For ea'
en1 Английский sam_2912 2022-06-23 08:56:41 605 Initial revision (published)