Welcome back to week three of the weekly programming contests! As always, you can find the rules and information on the contests Posted Here
This weeks challenge: is to implement the method:
public static String prefix(String sentence). (The method and variable can be renamed) This method takes in a sentence (which is a String containing 2 or more words) and returns the longest common prefix of the words in that sentence. Case is irrelevant, If there are two longest prefixes, it should return an empty String, but since i did not specify this case beforehand, any output is fine.
prefix(“Bob the bobbin builder”) -> “bob”
prefix(“Hello my name is Bob the happy lion”) -> “h”
prefix(“The quick brown dog jumped over a lazy fox”) -> “”
prefix(“There was a large patch of flowers growing near the flowing stream”) -> “flow”
prefix(“There once was a bird named Bill, who was friends with Bill the rhino”) -> “bill”
prefix(“I like to eat little puppies”) -> “li”
Imports will be allowed for this one!
Challenge Closes: Sunday 11/22/15