|
|
|
@ -1,10 +1,4 @@
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.math.*;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.collections4.*;
|
|
|
|
|
import org.apache.commons.lang3.*;
|
|
|
|
|
import org.apache.commons.math3.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Template code to help you parse the standard input
|
|
|
|
@ -12,16 +6,29 @@ import org.apache.commons.math3.*;
|
|
|
|
|
**/
|
|
|
|
|
class Solution {
|
|
|
|
|
|
|
|
|
|
public static void main( String[] args ) {
|
|
|
|
|
// hint: read values via Scanner methods
|
|
|
|
|
Scanner in = new Scanner( System.in );
|
|
|
|
|
public static void main( String[] args ) {
|
|
|
|
|
// hint: read values via Scanner methods
|
|
|
|
|
var scanner = new Scanner( System.in );
|
|
|
|
|
|
|
|
|
|
// code your solution here
|
|
|
|
|
Map<String, Integer> lastOccurrences = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
// code your solution here
|
|
|
|
|
int startIndex = 0;
|
|
|
|
|
int maxLength = 0;
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
|
|
|
|
// use error to write to console
|
|
|
|
|
System.err.println( "debug" );
|
|
|
|
|
while ( scanner.hasNext() ) {
|
|
|
|
|
Integer previousOccurrence = lastOccurrences.put( scanner.next(), index++ );
|
|
|
|
|
if ( previousOccurrence != null ) {
|
|
|
|
|
if ( previousOccurrence >= startIndex ) {
|
|
|
|
|
maxLength = Math.max( maxLength, index - 1 - startIndex );
|
|
|
|
|
startIndex = previousOccurrence + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
maxLength = Math.max( maxLength, index - startIndex );
|
|
|
|
|
|
|
|
|
|
// Write result with System.out.println()
|
|
|
|
|
System.out.println( "value" );
|
|
|
|
|
}
|
|
|
|
|
// Write result with System.out.println()
|
|
|
|
|
System.out.println( maxLength );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|