Skip to content

Update longest_increasing_subsequence.cpp #1646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,9 @@
#include <bits/stdc++.h>
using namespace std;



int findMax(int arr[], int length) {
int max = 0;
for (int i = 0; i < length; i++) {
if (max < arr[i]) {
max = arr[i];
}
}
return max;
}

int findLongestIncSubLength(int arr[],int length) {
int dp[length];
int i, j, max = 0;
int i, j, maxx = 0;

// Initialize Longest Increasing Subsequence values
for (i = 0; i < length; i++) {
Expand All @@ -32,9 +20,9 @@ int findLongestIncSubLength(int arr[],int length) {
dp[i] = dp[j] + 1;
}
}
maxx = max(maxx, dp[i]);
}
max = findMax(dp, length);
return max;
return maxx;
}

int main() {
Expand Down