From 5eaf1daec131ee9849ffc6e6bc0f47c6a44d08b3 Mon Sep 17 00:00:00 2001 From: Lin Zhu Date: Sun, 23 Sep 2018 10:55:46 -0400 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E5=8D=87=E5=AD=90=E5=BA=8F=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 找到第一个比x大的,更新那个值,记录更小的tail Reference: (Leetcode 300)(https://leetcode.com/problems/longest-increasing-subsequence/discuss/74824/JavaPython-Binary-search-O(nlogn)-time-with-explanation) --- notes/Leetcode 题解.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notes/Leetcode 题解.md b/notes/Leetcode 题解.md index 3e19a632..bdf03c8d 100644 --- a/notes/Leetcode 题解.md +++ b/notes/Leetcode 题解.md @@ -2781,7 +2781,7 @@ return ret; 定义一个 tails 数组,其中 tails[i] 存储长度为 i + 1 的最长递增子序列的最后一个元素。对于一个元素 x, - 如果它大于 tails 数组所有的值,那么把它添加到 tails 后面,表示最长递增子序列长度加 1; -- 如果 tails[i-1] < x <= tails[i],那么更新 tails[i-1] = x。 +- 如果 tails[i-1] < x <= tails[i],那么更新 tails[i] = x。 例如对于数组 [4,3,6,5],有: