Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

deepGajera18's blog

By deepGajera18, 4 years ago, In English

You are given two strings S and T. you need to find the largest common prefix of two strings S and T if we are allowed to swap two characters in one of the strings?

1 <= |S| <= 100000 1 <= |T| <= 100000

example: S = "abcab" and T = "abbac", then answer would be "abcab". (By swapping characters at index 2 and 4 in string T)

Note: you can perform swap operation at most one time either on string S or string T.

Full text and comments »

  • Vote: I like it
  • +20
  • Vote: I do not like it