Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

3540511717, 978-3540511717

More Books

Students also viewed these Databases questions