We are given with an array of char, return True if the sequence of char a, b, c appears in the array somewhere.
Example:
Array_abc(['a', 'x', 'a', 'b', 'c']) = True
Array_abc(['f', 'x', 'a', 'i', 'c', 't']) = True
Array_abc(['k', 'x', 'a', 'e', 'c']) = True
Code:
Output
Explanation:
Here one can easily be confused in the second line as we have taken range(len(char)-2), in almost all questions we use -1, but here we have used -2. This can be explained because with length-2, we can use i+1 and i+2 in the loop. As we have to find a sequence for three numbers.
need an explanation for this answer? contact us directly to get an explanation for this answer