Longest Increasing Subsequence - Dynamic Programming | C++ Placement Course | Lecture 35.8

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Literally itni gndi explanation hai na thuk bhi waste ni krna

tusharaggarwal
Автор

There is a little error in the recursive approach. eg in array 1 3 6 7 9 4 10 5 6.
I made some corrections.
int lis(int n, int *arr, int *dp)
{
if (dp[n] != -1)
return dp[n];
dp[n] = 1;
for (int i = 0; i < n; i++)
{
int x = lis(i, arr, dp);
if (arr[n] > arr[i])
dp[n] = max(dp[n], 1 + x);
}
return dp[n];
}
int longestSubsequence(int n, int a[])
{
// your code here
int *dp = new int[n];
for (int i = 0; i < n; i++)
dp[i] = -1;
dp[n -1] = lis(n-1, a, dp);
int mx = INT_MIN;
for (int i = 0; i < n; i++)
{
mx = max(mx, dp[i]);
}
return mx;
}

gauravupreti
Автор

error at 5:24 in pont no (3) .. output is max dp[k] k->0 to size of array

hritikrastogi
Автор

Aman bhaiyya, We would love a video on how and what to do and enter in IT/CS sector right after 12th

tahashaikh
Автор

Remember..all the folks.do understand dp with recursive+memorization

shivamkedia
Автор

tabulation vala code galat h, vo 100, 101, 102, 103, 50, 5 k liye 1 output de rha h, please check

deepanshumeena
Автор

The question explanation quality is so bad... He just interpreting the solution not how the things working actually, even no dry run...

IT__KumariTejaswini-xvii
Автор

where is the notes of web development?

dayarauth
Автор

Aesa lagta hai majburi me playlist banayi h.

piyushverma
Автор

In the tabulation method, ans should have initialize as 1 instead of 0, or else it will give wrong answer on cases like,
n = 1, a = {0}
Here the answer is 1 but the code shows 0 instead, which is pretty wrong!

sabibahmed
Автор

At 2:40 we compared Lis(i) with Lis(k)+1. Why we added 1 to Lis(k). Please someone explain

aadisinghania
Автор

This problem can be solved in NlogN time using Patience Sort

tulikamal
Автор

Why we need to take ans variable? Why dp[n] is not the answer in the bottom up method?

anoopsingh
Автор

is there a video dedicated solely to STL?

sober_junkie
Автор

Bhaiya I'm at beginning in previous videos you've told to solve some more problems how can I solve as a beginner

syedmdsylan
Автор

There is a channel name "GET SAGED" aaj usne ek video upload ki ha or direct is playlist ka joke banaya ha

cypher
Автор

you are hero aman bhayia for us but free me padhana mat chorna na

yashkumar
Автор

Bhai khud pd rhe ho ya hme samjha rhe ho ...kya mtlb aise tutorial ka aisa LG rha hai jaise video khatam krne ke liye start Kiya hai

SanjeevKumar-kgyu
Автор

respected sir, DP thodi tough lag rahi hai.Koi alternative method ya website bataiye jahan se thoda better samajh sake!!

amansrivastava
Автор

JAB TEREKO C++ USE KARNI HI NAHI THI TOH C++ KA TITLE DALA HI KYU *APSHABD*

skybeast