Question
Write a python3 function: def solution(A, Y) that accepts as arguments a list of integers and an integer run length. It must nd in that
Write a python3 function:
def solution(A, Y)
that accepts as arguments a list of integers and an integer run length. It must nd in that list all runs of run length consecutive numbers that increase or decrease by 1. It should return the list indices of the rst element of each run. If there are no consecutive runs it should return an empty list.
Feel free to rename the arguments in the function signature, e.g.: def solution(values, run_length):
Example: values=[1, 2, 3, 5, 10, 9, 8, 9, 10, 11, 7,8,7], run_length=3 returns [0, 4, 6, 7]
Additionally, please give comments on the code's runtime and space complexity.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started