tusharrawat831
BAN USER
- 0of 0 votes
AnswersDesign a system to efficiently find 10 top selling products on an online shopping site at a given time with a time window of say 20 minutes.
- tusharrawat831 in India
Say, every second 100 products buy count getting updated.
Which data structure && algorithm would be the best to design such kind of systems ?| Report Duplicate | Flag | PURGE
Accolite software Software Engineer System Design - 0of 0 votes
AnswersQ. find the number of ways a string can be formed from a matrix of characters.
- tusharrawat831 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 :
input:
N = 3 (length of string)
string = fit
matrix :
fitptoke
orliguek
ifefunef
tforitis
output: 5
explanation:
num of ways to make 'fit' from matrix chars are 5 as given below sequence:
(0,0) (0,1)(0,2)
(2,1) (2,0)(3,0)
(2,3) (1,3)(0,4)
(3,1) (2,0)(3,0)
(2,3) (3,4)(3,5)
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
Open Chat in New Window