Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Implement a function to find the longest increasing subsequence in an array.

Hard

Problem Statement

Implement a function to find the longest increasing subsequence in an array.

Sample Input

[ 10, 9, 2, 5, 3, 7, 101, 18 ]

Sample Output

4

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
// Find the longest increasing subsequence in an array function longestIncreasingSubsequence(arr) { // Initialize a dp array to store the length of subsequence up to each element // Update the dp array by comparing each element with previous elements } console.log(longestIncreasingSubsequence([ 10, 9, 2, 5, 3, 7, 101, 18 ]));
Log in or sign up to run or submit your code.Log inSign up
Input
[ 10, 9, 2, 5, 3, 7, 101, 18 ]
Expected Output
4