Array Searching code challenge
- by RCIX
Here's my (code golf) challenge:
Take two arrays of bytes and determine if the second array is a substring of the first. If it is, output the index at which the contents of the second array appear in the first. If you do not find the second array in the first, then output -1.
Example Input:
{ 63, 101, 245, 215, 0 } { 245, 215 }
Expected Output: 2
Example Input 2: { 24, 55, 74, 3, 1 } { 24, 56, 74 }
Expected Output 2: -1
Edit: Someone has pointed out that the bool is redundant, so all your function has to do is return an int representing the index of the value or -1 if not found.