Given an array of integers, the task is to find the length of the longest strict bitonic…
- User
Given an array of integers, the task is to find the length of the longest strict bitonic subsequence. A bitonic subsequence is defined as a subsequence that is either strictly increasing and then strictly decreasing, or strictly decreasing. Example: Input: arr[] = {1, 5, 2, 3, 4, 5, 3, 2} Output: 6 The Longest Strict Bitonic Subsequence is: {1, 2, 3, 4, 3, 2}. Input: arr[] = {1, 2, 5, 3, 6, 7, 4, 6, 5} Output: 5 Input format : The first line of input consists of an integer n representing the size of the array. The second line of input consists of n space-separated integers representing the elements of the array. Output format : The output should display "Longest length strict bitonic subsequence = " followed by the integer representing the length of the longest strict bitonic subsequence. Refer to the sample output for the formatting specifications. Code constraints : In this scenario, the given test cases will fall under the following constraints: 1 ≤ n ≤ 10 1 ≤ Elements of the array ≤ 50. Sample test cases : Input 1 : 8 1 5 2 3 4 5 3 2 Output 1 : Longest length strict bitonic subsequence = 6 Input 2 : 9 1 2 5 3 6 7 4 6 5 Output 2 : Longest length strict bitonic subsequence = 5
Code in JAVA
- Assistantjava