Welcome back to the weekly programming contests! If you are new to the contest or need a refresher don’t forget to read up on the rules and information Posted Here
NOTE: I have added a new rule to the book which is that submissions with compile time errors OR WARNINGS will not be accepted.
This week’s challenge is to write a method that takes in two Strings and returns the length of the shortest substring of the first string that contains all the characters of the second, and -1 if none exists. So your method take in exactly two Strings and returns one integer.
Your method should be case insensitive.
Examples:
shortest(“Hello”, “hell”) -> 4
(substring: “hell”)
shortest(“SpongePowered”, “power”) -> 5
(substring: “power”)
shortest(“SpongePowered”, “PWND”) -> 10
(substring: “ngepowered”)
shortest(“I once ate a pickle lol”, “PILL”) -> 8
(substring: “pickle l”)
shortest(“Did the quick brown fox jump over the lazy dog?!”, “OOOO”) -> 29
(substring: “own fox jump over the lazy do”)
shortest(“i’m really uncreative when it comes to thinking of examples”, “correct”) -> 28
(substring: “really uncreative when it co”)
Also, if you like these weekly programming problems, please make some suggestions for the contest or specific challenges (in the main thread)! This takes time out of my Sunday and its not always fun! Using suggested challenges makes it a lot faster and easier for me.
Imports are allowed for this challenge!
Challenge Closes: Sunday 2/7/16
Good luck!