-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlis-2.c
More file actions
34 lines (25 loc) · 759 Bytes
/
lis-2.c
File metadata and controls
34 lines (25 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>
int lis(int arr[], int n) {
// Implementation of LIS algorithm remains the same
// ...
}
int main() {
int n;
// Getting the size of the array from the user
printf("Enter the size of the array: ");
scanf("%d", &n);
int *arr = (int *)malloc(sizeof(int) * n);
// Getting the elements of the array from the user
printf("Enter the elements of the array:\n");
for (int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
// Computing the length of LIS
int length = lis(arr, n);
// Printing the length of LIS
printf("Length of Longest Increasing Subsequence is: %d\n", length);
// Freeing the dynamically allocated memory
free(arr);
return 0;
}