Substring of an vector of strings

how can i solve this question…i find the a bit same one on gfg but i couldn’t understand
@talhashamim001

@akshat42bajpai, just neet to find the length of longest prefix u can use trie data structure or sort all the string and just find the longest prefix in first and last word that will be the ans or refer https://www.geeksforgeeks.org/longest-common-prefix-using-word-by-word-matching/