【String】Colorful jewelry necklace problem

Question: There is a colored gemstone necklace, which is composed of many different kinds of gemstones, including rubies, sapphires, diamonds, emeralds, pearls, etc. One day the king gave a necklace to a scholar and said to him, you can take this necklace with you, but the queen likes ruby, sapphire, amethyst, emerald and diamond very much, I want you to cut the chain from the necklace Give me back a small section, which must contain all of these five gems, and you can take the rest with you. If you can't find one, you can't take one. Please help the scholar figure out how to slice the necklace to get the most gems.  


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325911848&siteId=291194637