Interview Question for Software Engineers
- 0of 0 votes
Q. find the number of ways a string can be formed from a matrix of characters.- tusharrawat831 December 29, 2019 in United States
It can start forming a word from any position in mat[i][j] and can go in any unvisited direction from the 8 directions available across every cell [i][j].
sample case :
N = 3 (length of string)
string = fit
num of ways to make 'fit' from matrix chars are 5 as given below sequence:
How can we solve it efficiently without doing DFS across every position [i][j], which makes time complexity exponential?
Is there a better way possible in terms of time complexity? Maybe caching of values or something!
| Report Duplicate | Flag | PURGE
Software Engineer Algorithm
Interview Type: Phone Interview
Open Chat in New Window