Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class LongestIncreasingSequence {
  4.  
  5.  
  6. public static void main(String[] args) {
  7. Scanner userInput = new Scanner(System.in);
  8.  
  9. int n = Integer.parseInt(userInput.nextLine());
  10.  
  11. int[] numbers = new int[n];
  12.  
  13. for (int i = 0; i < numbers.length; i++) {
  14. numbers[i] = Integer.parseInt(userInput.nextLine());
  15. }
  16.  
  17. int maxCount = 0;
  18.  
  19. for (int i = 0; i < numbers.length; i++) {
  20. int currentCount = 1;
  21. for (int j = i + 1; j < numbers.length; j++) {
  22. if (numbers[i] < numbers[j]) {
  23. currentCount++;
  24. if (currentCount > maxCount) {
  25. maxCount = currentCount;
  26. }
  27. } else {
  28. break;
  29. }
  30. }
  31. }
  32. System.out.println(maxCount);
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement