Think about something like strlen. It is a very simple loop that counts characters up to '\0'. There are no special cases: it doesn't matter if the string is empty, has one character or is longer.

What you might do is very similar to strlen, except you count items while they have the same value and you have to avoid walking past the end of the array.