Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class LongestIncreasingSequence {
- public static void main(String[] args) {
- Scanner userInput = new Scanner(System.in);
- int n = Integer.parseInt(userInput.nextLine());
- int[] numbers = new int[n];
- for (int i = 0; i < numbers.length; i++) {
- numbers[i] = Integer.parseInt(userInput.nextLine());
- }
- int maxCount = 0;
- for (int i = 0; i < numbers.length; i++) {
- int currentCount = 1;
- for (int j = i + 1; j < numbers.length; j++) {
- if (numbers[i] < numbers[j]) {
- currentCount++;
- if (currentCount > maxCount) {
- maxCount = currentCount;
- }
- } else {
- break;
- }
- }
- }
- System.out.println(maxCount);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement