Please help me write this function
A 123 array is an array that contains multiple repetitions of the values 1, 2, 3 in that order. For example {1, 2, 3, 1, 2, 3, 1, 2, 3} is a 123 array but {1, 2, 3, 1, 2} is not. Write a function named is123Array which returns 1 if its array argument is a 123 array, otherwise it returns 0.
If you are programming in Java or C#, the function prototype is int is123Array(int[ ] a)
More examples:
if a is return reason
{1, 2, 3, 3, 2, 1} 0 elements a[3], a[4], a[5] are not 1, 2, 3
{0, 1, 2, 3, 1, 2, 3} 0 elements a[0], a[1], a[2] are not 1, 2, 3
{1, 2, 3, 3, 2, 1, 1, 2, 3} 0 elements a[3], a[4], a[5] are not 1, 2, 3
{1, 2, 3} 1
{} 0 must contain at least one 1, 2, 3 triad
A 123 array is an array that contains multiple repetitions of the values 1, 2, 3 in that order. For example {1, 2, 3, 1, 2, 3, 1, 2, 3} is a 123 array but {1, 2, 3, 1, 2} is not. Write a function named is123Array which returns 1 if its array argument is a 123 array, otherwise it returns 0.
If you are programming in Java or C#, the function prototype is int is123Array(int[ ] a)
More examples:
if a is return reason
{1, 2, 3, 3, 2, 1} 0 elements a[3], a[4], a[5] are not 1, 2, 3
{0, 1, 2, 3, 1, 2, 3} 0 elements a[0], a[1], a[2] are not 1, 2, 3
{1, 2, 3, 3, 2, 1, 1, 2, 3} 0 elements a[3], a[4], a[5] are not 1, 2, 3
{1, 2, 3} 1
{} 0 must contain at least one 1, 2, 3 triad