Back to Browse

DP - 4: Get Longest Increasing Subsequence Length

6.2K views
Feb 7, 2020
20:51

Source Code:https://thecodingsimplified.com/longest-increasing-subsequence/ Solution: - We initialize an array, where initial value for each number is set to 1, because a number is also a subsequence of length 1 - Now we'll traverse in a loop from 2nd element of array & will keep chekcing with every element that if this is greater than previous one & if it's LIS(j) + 1 greater than LIS(j), then update the LIS of current value - On the same time, we also store a variable as max, which will hold the maximum value Time Complexity: O(n^2) Space Complexity: O(n) Do Watch video for more info CHECK OUT CODING SIMPLIFIED https://www.youtube.com/codingsimplified ★☆★ VIEW THE BLOG POST: ★☆★ http://thecodingsimplified.com I started my YouTube channel, Coding Simplified, during Dec of 2015. Since then, I've published over 400+ videos. ★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★ https://www.youtube.com/codingsimplified?sub_confirmation=1 ★☆★ Send us mail at: ★☆★ Email: [email protected]

Download

0 formats

No download links available.

DP - 4: Get Longest Increasing Subsequence Length | NatokHD