Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.telerikacademy;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class LongestIncreasingSequence {
- public static void main(String[] args) throws IOException {
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- short num = Short.parseShort(br.readLine());
- short[] arr = new short[num];
- maximalIncreasingSequence(br, num, arr);
- }
- private static void maximalIncreasingSequence(BufferedReader br, short num, short[] arr) throws IOException {
- short maxSubStrLength = 1;
- short tempMaxLength = 1;
- arr[0] = Short.parseShort(br.readLine());
- for (short i = 1; i < num; i++) {
- arr[i] = Short.parseShort(br.readLine());
- if (arr[i - 1] < arr[i]) {
- ++tempMaxLength;
- } else if (tempMaxLength > maxSubStrLength) {
- maxSubStrLength = tempMaxLength;
- tempMaxLength = 1;
- }
- }
- if (tempMaxLength > maxSubStrLength) {
- maxSubStrLength = tempMaxLength;
- }
- System.out.println(maxSubStrLength);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement