Below is an example of a repeating cycle.
is_repeating_cycle([1, 2, 3, 1, 2], 3) ➞ true
# Since the first two elements of [1, 2, 3] equals [1, 2]Below is an example of a non-repeating cycle.
is_repeating_cycle([1, 2, 3, 1, 3], 3) ➞ false
# Since [1, 2, 3] != [1, 3]You are tasked with writing a function that takes in two inputs:
Return the boolean value true if the array is a repeating cycle, and false if the array is a non-repeating cycle.
is_repeating_cycle([1, 2, 3, 1, 2, 3, 1], 3) ➞ true
is_repeating_cycle([1, 2, 3, 4, 2, 3, 1], 4) ➞ false
is_repeating_cycle([1, 2, 1, 2, 2], 2) ➞ false
is_repeating_cycle([1, 1, 1, 1], 3) ➞ truetrue if the cycle length is greater than the array length.