-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Description:
There is a secret string which is unknown to you. Given a collection of random triplets from the string, recover the original string.
A triplet here is defined as a sequence of three letters such that each letter occurs somewhere before the next in the given string. "whi" is a triplet for the string "whatisup".
As a simplification, you may assume that no letter occurs more than once in the secret string.
You can assume nothing about the triplets given to you other than that they are valid triplets and that they contain sufficient information to deduce the original string. In particular, this means that the secret string will never contain letters that do not occur in one of the triplets given to you.
給定一連串的 triplets,推斷出原字串。
一個 triplet 由三個字母組成,順序跟原字串的順序一致。例如:原字串 "whatisup" 的 triplet 可能為 "whi"、"tup"、"hip"... 等。
為了簡化題目,可以假設:
- 每個字母只會出現一次
- 給的 triplets 一定可以還原出原字串
題目網址:https://www.codewars.com/kata/recover-a-secret-string-from-random-triplets