Consecutive Characters Problem Statement
Given a matrix of lowercase characters with dimensions 'N' rows and 'M' columns, and a string 'STR', your goal is to find the longest consecutive character path length for each character in 'STR'. Characters in the path should be consecutive in alphabetical order, and movement is allowed in all 8 adjacent directions from a cell.
Example:
Input:
N = 2, M = 2, STR = "a"
Matrix:
a b
e d
Output:
[2]
Explanation:
The longest path starting with 'a' is [a, b]. Therefore, the length is 2.
Constraints:
1 <= T <= 10
1 <= M <= 300
1 <= N <= 300
‘a’ <= matrix[i][j], STR[i] <= ‘z’
1 <= |STR| <= 26
- Time Limit: 1 sec
Note:
You may move to the following positions from (x, y):
[(x+1, y), (x-1, y), (x, y+1), (x, y-1), (x+1, y+1), (x+1, y-1), (x-1, y+1), (x-1, y-1)]
Find the longest consecutive character path length for each character in a matrix given a string.
Iterate through the matrix and for each character in the string, find the longest consecutive path in a...read more
Top Info Edge Test Engineer interview questions & answers
Popular interview questions of Test Engineer
Reviews
Interviews
Salaries
Users/Month