Decreasing Subsequent Values

Start Timer

0:00:00

Upvote
9
Downvote
Save question
Mark as completed
View comments (18)

Given an integer array arr, write a function decreasing_values to return an array of integers so that the subsequent integers in the array get filtered out if they are less than an integer in a later index of the array.

Example 1:

Input:

arr = [20,17,19,18,12,16,10,4,6,3]

def decreasing_values(arr) -> [20,19,18,16,10,6,3]

Example 2:

Input:

arr = [25,30,21,22,14,10,5,26]

def decreasing_values(arr) -> [30,26]
.
.
.
.
.


Comments

Loading comments