█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 2082

Problema 0x43 - Encontrar el borde más largo de una string

  • Autor: aebernalmunoz
  • Fecha: 2020-11-21 19:33:41 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.231 s 13 KBi
#2
Correcto
0.211 s 13 KBi
#3
Correcto
0.204 s 13 KBi
#4
Correcto
0.208 s 13 KBi
#5
Correcto
0.225 s 13 KBi
#6
Correcto
0.216 s 13 KBi
#7
Tiempo límite excedido
0.708 s 18 KBi
#8
Tiempo límite excedido
1.057 s 17 KBi
#9
Tiempo límite excedido
0.876 s 17 KBi
#10
Tiempo límite excedido
0.907 s 18 KBi
#11
Tiempo límite excedido
1.063 s 18 KBi
#12
Correcto
0.601 s 18 KBi
#13
Tiempo límite excedido
1.029 s 18 KBi
#14
Tiempo límite excedido
0.817 s 18 KBi
#15
Tiempo límite excedido
0.662 s 16 KBi
#16
Tiempo límite excedido
0.816 s 17 KBi
#17
Correcto
0.393 s 17 KBi
#18
Incorrecto
0.372 s 18 KBi
#19
Incorrecto
0.403 s 18 KBi
#20
Incorrecto
0.432 s 18 KBi
#21
Correcto
0.377 s 17 KBi
#22
Correcto
0.353 s 17 KBi
Puntos totales: 46 / 100

Código

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

		String s = sc.nextLine();
		sc.close();
		int count = 0, len = s.length();
		int nextborder = 1, border, i;
		int largest = 0;
		while ((nextborder = s.indexOf(s.charAt(0), nextborder)) != -1) {
			border = nextborder;
			i = 0;
			count = 0;
			while (border < len && s.charAt(i++) == s.charAt(border++)) {
				count++;
			}
			largest = Math.max(largest, count);
			nextborder++;
		}
		System.out.println(largest);

	}
}