Interview Query

Decreasing Subsequent Values

2
Have you seen this question before?

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]
Next question: Stratified Split
.....
Python 3.9.6
Loading editor
Use Shift + Enter to run code