Find the longest incremental sequence in the Rectangular Mesh
Find the longest incremental sequence in the Rectangular mesh, for example, the following grids 97,47, 56,3635, 57,41, 1389,36, 98,7525, 45 ,26, 17, and the output results must be 17, 26, 36, 41, 47, 56, 57. 97 the basic idea is to use each vertex in the graph as the starting point to save the longest sequence. The final output code is as follows: use java to write import java. util. arrayList; Maximum ascending sequence of public class {static int [] [] rect = {,}, {,}, {}, {, 45, 26, 17 }}; static ArrayList
Al = new ArrayList
(); Static ArrayList
LongMax = new ArrayList
(); Public static void main (String [] args) {for (int I = 0; I
();} System. out. println (longMax);} public static void seek (int bx, int by) {al. add (rect [bx] [by] + ""); if (al. size ()> longMax. size () longMax = new ArrayList (al); for (int x =-1; x <= 1; x ++) for (int y =-1; y <= 1; y ++) if (0 <= bx + x & 0 <= by + y & bx + x <= 3 & by + y <= 3 & rect [bx] []