SlavCodes

Untitled

Sep 4th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import java.util.*;
  2. public class Test3 {
  3.  
  4. public static void main(String[] args) {
  5. Scanner reader = new Scanner(System.in);
  6. int input = Integer.parseInt(reader.nextLine());
  7. int longer =1;
  8. int longest =1;
  9. String[] myArr = new String[input];
  10. myArr[0] = reader.nextLine();
  11. for (int i = 1; i <input ; i++) {
  12. myArr[i] = reader.nextLine();
  13. if(myArr[i].equals(myArr[i-1])){
  14. longer++;
  15. if(longer>longest){
  16. longest=longer;
  17. }
  18. }else{
  19. longer=1;
  20. }
  21. }
  22. System.out.println(longest);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment