{"trustable":false,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003chtml\u003e\n \u003chead\u003e\u003c/head\u003e\n \u003cbody\u003e\n \u003cdiv id\u003d\"problem-body\"\u003e \n \u003cp\u003eYou will be given a 2-dimensional grid of letters. Find the length of the longest path of consecutive letters, starting at \u0027A\u0027. Paths can step from one letter in the grid to any adjacent letter (horizontally, vertically, or diagonally).\u003c/p\u003e \n \u003cp\u003eFor example, in the following grid, there are several paths from \u0027A\u0027 to \u0027D\u0027, but none from \u0027A\u0027 to \u0027E\u0027:\u003c/p\u003e \n \u003cdiv\u003e \n \u003cimg title\u003d\"ABC\" src\u003d\"CDN_BASE_URL/3b752bcc214cdbbf416d79bab97bde31?v\u003d1621738442\" alt\u003d\"ABC\" width\u003d\"162\" height\u003d\"108\"\u003e \n \u003c/div\u003e \n \u003cp\u003eOne such path is:\u003c/p\u003e \n \u003cp\u003e\u003cimg title\u003d\"ABC path\" src\u003d\"CDN_BASE_URL/a8949658a9cb6325e9ef55b06bc0d62a?v\u003d1621738442\" alt\u003d\"path\" width\u003d\"163\" height\u003d\"108\"\u003e\u003c/p\u003e \n \u003ch3\u003eInput\u003c/h3\u003e \n \u003cp\u003eEach test case will start with a line contains two integers H, W the height and width of the grid respectively 1 \u0026lt;\u003d H, W \u0026lt;\u003d 50. Then H lines follow each of W uppercase letters only. Input terminates with H \u003d 0 and W \u003d 0.\u003c/p\u003e \n \u003ch3\u003eOutput\u003c/h3\u003e \n \u003cp\u003eFor each test case print \u003ctt\u003e“Case C: X”\u003c/tt\u003e without quotes where C is the case number starting with 1 and X is the solution.\u003c/p\u003e \n \u003ch3\u003eExample\u003c/h3\u003e \n \u003cpre\u003e\u003cstrong\u003eSample Input:\u003c/strong\u003e\n4 3\nABE\nCFG\nBDH\nABC\n0 0\n\n\u003cstrong\u003eSample Output:\u003c/strong\u003e\nCase 1: 4\u003c/pre\u003e \u003c!-- Note: The underscore \u0027_\u0027 symbol is only for clarity you should print space instead. --\u003e \n \u003c/div\u003e\n \u003c/body\u003e\n\u003c/html\u003e"}}]}