Module solve_leetcode::problems::problem_0651::recursion[][src]

Expand description

f(n) = max( // A f(n - 1) + 1, // Ctrl-V g(n, 1), )

f(1) = 1 f(2) = 2

g(i, j) means the last j steps are Ctrl-V (j <= i - 3)

g(i, j) = max( // Either the previous step is also Ctrl-V g(i, j + 1), // or the previous two steps are Ctrl-A + Ctrl-C f(i - j - 2) * (j + 1) ) }

Re-exports

pub use f as solve;

Functions