Problems > Longest Common Suffix

Longest Common Suffix

Difficulty: 1100 2000 ms 128 MB

strings

Print the longest suffix shared by all N words, or NONE.

Input: the first line has N; the next N lines each have one lowercase word.

Output: the longest common suffix, or NONE.

Constraints:

  • 2 ≤ N ≤ 100
  • 1 ≤ word length ≤ 100

Sample Tests

Input 1
3
walking
talking
baking
Output 1
king
Input 2
2
abc
xyz
Output 2
NONE

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.