{"id":"78e2df06-7478-441b-beb5-02b512f24aac","name":"Longest Bitonic Subsequence","description":"1. You are given a number n, representing the number of elements.\r\n2. You are given n numbers, representing the contents of array of length n.\r\n3. You are required to print the length of longest bitonic subsequence of array.\r\nNote -> bitonic subsequence begins with elements in increasing order, followed by elements in decreasing order.","inputFormat":"A number n\r\n.. n more elements","outputFormat":"A number representing the length of longest increasing subsequence of array.","constraints":"0 <= n <= 20\r\n0 <= n1, n2, .. <= 100","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"10\r\n10\r\n22\r\n9\r\n33\r\n21\r\n50\r\n41\r\n60\r\n80\r\n1","sampleOutput":"7","questionVideo":"https://www.youtube.com/embed/jdfpGSSyN2I?end=30","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"07e300f9-853a-4cfc-9328-06475fa8cc6a","name":"Longest Bitonic Subsequence","slug":"longest-bitonic-subsequence","type":1}],"next":{"id":"f90da01a-c2ba-4d16-ae42-046722214bb4","name":"Longest Common Subsequence","type":1,"slug":"longest-common-subsequence"},"prev":{"id":"497198c6-c788-44aa-b37f-f6ae8369aa08","name":"Longest Increasing Subsequence","type":1,"slug":"longest-increasing-subsequence"}}}

Longest Bitonic Subsequence

1. You are given a number n, representing the number of elements. 2. You are given n numbers, representing the contents of array of length n. 3. You are required to print the length of longest bitonic subsequence of array. Note -> bitonic subsequence begins with elements in increasing order, followed by elements in decreasing order.

{"id":"78e2df06-7478-441b-beb5-02b512f24aac","name":"Longest Bitonic Subsequence","description":"1. You are given a number n, representing the number of elements.\r\n2. You are given n numbers, representing the contents of array of length n.\r\n3. You are required to print the length of longest bitonic subsequence of array.\r\nNote -> bitonic subsequence begins with elements in increasing order, followed by elements in decreasing order.","inputFormat":"A number n\r\n.. n more elements","outputFormat":"A number representing the length of longest increasing subsequence of array.","constraints":"0 <= n <= 20\r\n0 <= n1, n2, .. <= 100","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"10\r\n10\r\n22\r\n9\r\n33\r\n21\r\n50\r\n41\r\n60\r\n80\r\n1","sampleOutput":"7","questionVideo":"https://www.youtube.com/embed/jdfpGSSyN2I?end=30","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"07e300f9-853a-4cfc-9328-06475fa8cc6a","name":"Longest Bitonic Subsequence","slug":"longest-bitonic-subsequence","type":1}],"next":{"id":"f90da01a-c2ba-4d16-ae42-046722214bb4","name":"Longest Common Subsequence","type":1,"slug":"longest-common-subsequence"},"prev":{"id":"497198c6-c788-44aa-b37f-f6ae8369aa08","name":"Longest Increasing Subsequence","type":1,"slug":"longest-increasing-subsequence"}}}
plane

Editor


Loading...

Longest Bitonic Subsequence

easy

1. You are given a number n, representing the number of elements. 2. You are given n numbers, representing the contents of array of length n. 3. You are required to print the length of longest bitonic subsequence of array. Note -> bitonic subsequence begins with elements in increasing order, followed by elements in decreasing order.

Constraints

0 <= n <= 20 0 <= n1, n2, .. <= 100

Format

Input

A number n .. n more elements

Output

A number representing the length of longest increasing subsequence of array.

Example

Sample Input

10 10 22 9 33 21 50 41 60 80 1

Sample Output

7

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode