This is a interview problem I met on an onsite interview (actually the second round), which is defined by the interviewers the top-hard problems of their interview-problem library.
Since I was rejected after the 8-round interview (one online test, three onsite algorithm problems and four culture fit interviews) and we had no agreement on sharing stuff, so here it is.
You are given a NxN matrix composed of lowercase letters and a list of words. Your task is to find out the largest list of words that can be formed by the letters in the matrix.
{
{‘o’, ‘a’, ‘a’, ‘n’},
{‘e’, ‘t’, ‘a’, ‘e’},
{‘i’, ‘h’, ‘k’, ‘r’},
{‘i’, ‘f’, ‘l’, ‘v’}
}
{“eat”, “oath”, “aak”, “ner”, “oei”, “thfl”}
{“oei”, “ner”, “aak”, “thfl”}
Actually all these words can be formed in the matrix, but we have to ensure the biggest list of words.