fork download
  1. public class Main
  2. {
  3. public static int getLongestSubstringNoRepeats( String string ){
  4. int iLongestSoFar = 0;
  5. char charPrevious = 0;
  6. int xCharacter = 0;
  7. int iCurrentLength = 0;
  8. while( xCharacter < string.length() ){
  9. char charCurrent = string.charAt( xCharacter );
  10. iCurrentLength++;
  11. if( charCurrent == charPrevious ){
  12. if( iCurrentLength > iLongestSoFar ) iLongestSoFar = iCurrentLength;
  13. iCurrentLength = 1;
  14. }
  15. charPrevious = charCurrent;
  16. }
  17. return iCurrentLength > iLongestSoFar ? iCurrentLength : iLongestSoFar;
  18. }
  19.  
  20. public static void main(String[] args)
  21. {
  22. System.out.println(getLongestSubstringNoRepeats("AABGAKGIMN"));
  23. }
  24. }
Runtime error #stdin #stdout #stderr 4.99s 380160KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
/spoj/java_run: line 9: 29910 CPU time limit exceeded /opt/$VER/bin/java -client -Xbatch -Dfile.encoding=UTF-8 -jar tested.zip