Download benchmarks/Algorithms/longest_increasing_subsequence/solution.c from PV-SJTU/PV-Bench: direct link, hf CLI and curl.
- Browser
- Download file 391 Bytes
-
https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/longest_increasing_subsequence/solution.c
- Command line
-
hf download hf://datasets/PV-SJTU/PV-Bench/benchmarks/Algorithms/longest_increasing_subsequence/solution.c
-
curl -L -o solution.c https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Algorithms/longest_increasing_subsequence/solution.c
391 Bytes
| int lengthOfLIS(int *nums, int numsSize) | |
| { | |
| int dp[100000]; | |
| int ans = 1; | |
| for (int i = 0; i < numsSize; ++i) { | |
| dp[i] = 1; | |
| for (int j = 0; j < i; ++j) { | |
| if (nums[j] < nums[i]) { | |
| int candidate = dp[j] + 1; | |
| if (candidate > dp[i]) { | |
| dp[i] = candidate; | |
| } | |
| } | |
| } | |
| if (dp[i] > ans) { | |
| ans = dp[i]; | |
| } | |
| } | |
| return ans; | |
| } | |