Implement an efficient O(n log n) solution to find the longest increasing subsequence in an array.
HardProblem Statement
Implement an efficient O(n log n) solution to find the longest increasing subsequence in an array.
Sample Input
[10, 9, 2, 5, 3, 7, 101, 18]
Sample Output
4
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
package main
import "fmt"
func longestIncreasingSubsequence(arr []int) int {
// Your code here
}
func main() {
arr := []int{10, 9, 2, 5, 3, 7, 101, 18}
fmt.Println(longestIncreasingSubsequence(arr)) // Expected Output: 4
}
Input
[10, 9, 2, 5, 3, 7, 101, 18]
Expected Output
4