狗家 题 讨论# JobHunting - 待字闺中
c*n
1 楼
1. Given a array of integers , find 3 indexes i,j,k such that, i ] < a[j] < a[k]. Best possible is a O(n) algorithm.
这个就现在这样可以就设三个点,每个 新点来了对比这三个参照。就是写好些if else
但如果推广到 要求找K element 长的递增的subsequence, 怎么办?I guess u could
simply use "find the longest increasing subsequence", but if the actual LIS
is much longer than K, maybe simpler methods exist to simply find ONE
subsequence longer than K?
这个就现在这样可以就设三个点,每个 新点来了对比这三个参照。就是写好些if else
但如果推广到 要求找K element 长的递增的subsequence, 怎么办?I guess u could
simply use "find the longest increasing subsequence", but if the actual LIS
is much longer than K, maybe simpler methods exist to simply find ONE
subsequence longer than K?