fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. class Solution {
  13. int solution(int[] A, int K) {
  14. int n = A.length;
  15. int best = 0;
  16. int count = 1;
  17. for (int i = 0; i < n - K - 1; i++) {
  18. if (A[i] == A[i + 1])
  19. count = count + 1;
  20. else
  21. count = 0;
  22. if (count > best)
  23. best = count;
  24. }
  25. int result = best + 1 + K;
  26.  
  27. return result;
  28. }
  29. }
  30. }
  31. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
Standard output is empty