Array Max Increasing Index LeetCode (Longest Increasing SubArray or Longest Increasing Subsequence)

Given an array arr[], find the maximum j – i such that arr[j] > arr[i].

Example 1:
  •  Input: {34, 8, 10, 3, 2, 80, 30, 33, 1}
  •  Output: 6  (j = 7, i = 1)
Example 2
  • Input: {9, 2, 3, 4, 5, 6, 7, 8, 18, 0}
  •   Output: 8 ( j = 8, i = 0)
Example 3:  
  • Input:  {1, 2, 3, 4, 5, 6}
  •   Output: 5  (j = 5, i = 0)
Example 4: 
  •  Input:  {6, 5, 4, 3, 2, 1}
  •   Output: -1 

This problem is also popular in GeeksForGeeks and LeetCode A collection of hundreds of interview questions and solutions are available in our blog at Interview Question Solutions

Solution:

 

 

No comments:

Post a Comment