I'm new here and also new to Python. So, this is my question and I really don't know where to start. I created a list and wrote liste.add(str(input('input a string')))
. Can you help me, thanks.
I have N strings
and the target is to obtain maximum points by concatenating some of these strings. If we want to add string "B" after string "A" they should satisfy rules below:
● "A" should be lexicographically smaller than "B".
● Some suffix of "A" (with minimum length of 1) should be same with some prefix of "B". Ex: last three characters of string “abaca” is same with first three characters of string “acaba”.
● After concatenating string "A" and "B", we gain points equal to length of their overlap(3 for example above)
Range 1 ≤ N ≤ 500
1 ≤ | Si | ≤ 500 (Length of any string)
Input Format:
In the first line there will be number (number of strings). Next lines there will be strings we have (all of them contains only lowercase English character)
Output Format:
In single line, print the maximum points can user get.
Sample Input : 4 a ba ab acaba
Sample Output : 3
Explanation:
With a - acaba - ba order, user can get 1 + 2 = 3 points.