Solve two string algorithm tasks | Meta Interview Question