`{"id":"dbfcbf4f-9c92-4e06-a6e2-c970e5156075","name":"Longest Increasing 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 increasing subsequence of array.","inputFormat":"A number n\r\n.. n more elements","outputFormat":"A number representing the length of longest increasing subsequence of array.","constraints":"0 &lt;= n &lt;= 20\r\n0 &lt;= n1, n2, .. &lt;= 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":"medium","sampleInput":"10\r\n10\r\n22\r\n9\r\n33\r\n21\r\n50\r\n41\r\n60\r\n80\r\n1","sampleOutput":"6","questionVideo":"https://www.youtube.com/embed/odrfUCS9sQk?end=130","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":"497198c6-c788-44aa-b37f-f6ae8369aa08","name":"Longest Increasing Subsequence","slug":"longest-increasing-subsequence","type":1}],"next":{"id":"07e300f9-853a-4cfc-9328-06475fa8cc6a","name":"Longest Bitonic Subsequence","type":1,"slug":"longest-bitonic-subsequence"},"prev":{"id":"44f25b8f-9b99-4e1d-a35e-e92082b43088","name":"Maximum Non-overlapping Bridges","type":1,"slug":"maximum-non-overlapping-bridges"}}}`

Longest Increasing 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 increasing subsequence of array.

`{"id":"dbfcbf4f-9c92-4e06-a6e2-c970e5156075","name":"Longest Increasing 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 increasing subsequence of array.","inputFormat":"A number n\r\n.. n more elements","outputFormat":"A number representing the length of longest increasing subsequence of array.","constraints":"0 &lt;= n &lt;= 20\r\n0 &lt;= n1, n2, .. &lt;= 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":"medium","sampleInput":"10\r\n10\r\n22\r\n9\r\n33\r\n21\r\n50\r\n41\r\n60\r\n80\r\n1","sampleOutput":"6","questionVideo":"https://www.youtube.com/embed/odrfUCS9sQk?end=130","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":"497198c6-c788-44aa-b37f-f6ae8369aa08","name":"Longest Increasing Subsequence","slug":"longest-increasing-subsequence","type":1}],"next":{"id":"07e300f9-853a-4cfc-9328-06475fa8cc6a","name":"Longest Bitonic Subsequence","type":1,"slug":"longest-bitonic-subsequence"},"prev":{"id":"44f25b8f-9b99-4e1d-a35e-e92082b43088","name":"Maximum Non-overlapping Bridges","type":1,"slug":"maximum-non-overlapping-bridges"}}}`

Editor

Longest Increasing Subsequence

medium

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 increasing subsequence of array.

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

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}10 10 22 9 33 21 50 41 60 80 1```

Sample Output

`.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}6`

Question Video

Discussions

Show Discussion

Related Resources