Easy solution using Longest Increasing Subsequence method

int Solution::solve(vector<vector<int> > &A) {
    for(int i=0;i<A.size();i++){
        for(int j=0;j<i;j++){
            if(A[i][0]>A[j][1]) dp[i]=max(1+dp[j],dp[i]);
    return *max_element(dp.begin(),dp.end());
1 Like

Thanks! Iā€™m still leaning DP technique, but your code is easy to understand for me!

For other people like me, I share my note.

Click here to start solving coding interview questions