Skip to content

Commit 5d87f42

Browse files
committed
Longest Increasing subsequence using binary search most optimal approach for this problem
1 parent a9c309e commit 5d87f42

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

search/Longest_Increasing_Subsequence_using_binary_search.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* @file
44
* @brief find the length of the Longest Increasing Subsequence (LIS)
5-
* using Binary Search(https://en.wikipedia.org/wiki/Longest_increasing_subsequence)
5+
* using [Binary Search](https://en.wikipedia.org/wiki/Longest_increasing_subsequence)
66
* @details
77
* Given an integer array nums, return the length of the longest strictly
88
* increasing subsequence.
@@ -90,6 +90,12 @@ static void tests() {
9090
std::vector<int> arr3 = {7, 7, 7, 7, 7, 7, 7};
9191
assert(longest_increasing_subsequence_using_binary_search(arr3) == 1);
9292

93+
std::vector<int> arr4 = {-10, -1, -5, 0, 5, 1, 2};
94+
assert(longest_increasing_subsequence_using_binary_search(arr4) == 5);
95+
96+
std::vector<int> arr5 = {};
97+
assert(longest_increasing_subsequence_using_binary_search(arr5) == 0);
98+
9399
std::cout << "All tests have successfully passed!\n";
94100
}
95101

0 commit comments

Comments
 (0)