No.1 array series solution ideas
A for loop resolves.
The code shown
No.2 Different gyronic subsequences of length 3
Their thinking
There are at most 26 * 26 gyrotext subsequences of length 3, and the existence of each seed sequence can be judged in turn.
The code shown
No.3 paints the mesh with three different colors
Their thinking
By pressing DP, each column can be compressed into a number between 0 and 242 (equivalent to the representation in base 3).
Define state dpi to represent the number of schemes in column I when the coloring condition of column I is j.
Dpi = SUM(dpi – 1) if valid(j) and valid(k) and valid(j, k)
In the equation, valid(j) means that j itself is a valid coloring (no adjacent columns of the same color), and valid(j, k) means that it is valid to coloring j and k as adjacent columns.
The code shown
No.4 Merges multiple binary search trees
Their thinking
DFS is fine, see the notes for details.
The code shown