David Smith

David Smith

  • NA
  • 2k
  • 0

Findstring: anagram of “matchSet.”

Oct 17 2015 11:58 PM

1. IImplement the function below. Your function should search “inputString” for any possible anagram of “matchSet.” That is, any contiguous set of characters that contains every character in “matchSet” in any order, exactly once, and with no extra characters in the set. Return the index of the starting point of the first match, or -1 if no match is found. Return -1 if no match is found. Optimize for speed assuming that “matchSet” and “inputString” may both be very large.

For example:

findString("ba", "cccabcc"); //returns 3

findString("cat", "cacatcatc"); //returns 2

findString("ba", "ccccccc"); //returns -1

int findString(string matchSet, string inputString)

{

// your code

}


Answers (10)