About my solution: - s is the collection of strings. - maxstring[i] stores the index of the string that starts from position i and has greater length than all the other ones starting at i. - ans (string) stores the final answer. - maxsize denotes the size of the ans.
Edit 1: Changing N from to 2e6+6 gives me TLE. How did this happen?