Math, asked by Banavathharsha700, 1 year ago

Given n words w[1..N], which originate from the same stem (e.G. Grace, graceful, disgraceful, gracefully), we are interested in the original stem. To simplify the problem, we define the stem as the longest consecutive substring that occurs in all the n words. If there are ties, we will choose the smallest one in the alphabetical (lexicographic) order.

Answers

Answered by amitnrw
0

Answer:

ACE

Step-by-step explanation:

Given n words w[1..N], which originate from the same stem (e.G. Grace, graceful, disgraceful, gracefully), we are interested in the original stem. To simplify the problem, we define the stem as the longest consecutive substring that occurs in all the n words. If there are ties, we will choose the smallest one in the alphabetical (lexicographic) order.

Grace, graceful, disgraceful, gracefully

if we remove G from Grace then we can get

Race

now if we remove r from race then we can get

ace

So  sequence would be

ace

race

grace

graceful

disgraceful

gracefully

ACE is the smallest one

Similar questions