From 76b43300171e8713ce427e73b6aa474dbbbb6309 Mon Sep 17 00:00:00 2001 From: Praggya17 <71866834+Praggya17@users.noreply.github.com> Date: Sat, 28 Oct 2023 17:24:02 +0530 Subject: [PATCH] Create longestIncreasingSubsequence_dp --- longestIncreasingSubsequence_dp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 longestIncreasingSubsequence_dp diff --git a/longestIncreasingSubsequence_dp b/longestIncreasingSubsequence_dp new file mode 100644 index 0000000..09529ea --- /dev/null +++ b/longestIncreasingSubsequence_dp @@ -0,0 +1,18 @@ +class Solution { +public: + int lengthOfLIS(vector& nums) { + int n = nums.size(); + vector dp(n,1); + for(int i=0;i nums[j]) + { + dp[i] = max(dp[i],dp[j]+1); + } + } + } + return *max_element(dp.begin(),dp.end()); + } +};