1 // Copyright (C) The Lightning Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
7 func longestIncreasingSubsequence(srclen int, X func(int) int) []int {
11 M := make([]int, srclen+1) // M[j] == index into X such that X[M[j]] is the smallest X[k] where k<=i and an increasing subsequence with length j ends at X[k]
12 P := make([]int, srclen) // P[k] == index in X of predecessor of X[k] in longest increasing subsequence ending at X[k]
13 L := 0 // length of longest increasing subsequence found so far
17 mid := (lo + hi + 1) / 2
34 for k, i := M[L], len(ret)-1; i >= 0; k, i = P[k], i-1 {