A week ago I got my homework, where I have to write a function in C. The function gets a single array of positive integers, and it has to return the next number in the array. The arrays look something like this: {1,2,3,1,2,3,4,1,2,3,1,2,3,4,1,2,3,-1}; -1 means the end of the array.
I know that the number which has to be returned by the function is 1, however, how can I code a pattern finding algorithm? I haven't found any solution on the internet, since every other question about pattern searching is with strings, where the pattern which has to be found is already given.