Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- public class Main {
- public static int algo(int[] arr, int[] d, int index, int dmax) {
- if (index == arr.length) {
- return dmax + 1;
- }
- if (arr[index] > arr[index - 1]) d[index] = dmax + 1;
- else d[index] = 0;
- if (d[index] > d[index - 1]) dmax = d[index];
- return algo(arr, d, index + 1, dmax);
- }
- public static void main(String[] args) {
- int arr[] = {4, 5, 7, 2, 1, 13, 18};
- int d[] = new int[arr.length];
- for (int i = 0; i < arr.length; i++) {
- d[i] = 0;
- }
- System.out.println(algo(arr, d, 1, 0));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement