#C7393. Filter Elements Within a Range
Filter Elements Within a Range
Filter Elements Within a Range
You are given a list of integers and two numbers \(L\) and \(H\). Your task is to output a new list containing only those elements from the original list that lie in the range \([L, H]\) (inclusive).
Example 1:
Input: 7 1 5 8 12 4 18 3 4 10 Output: 5 8 4
Example 2:
Input: 4 20 30 40 50 25 45 Output: 30 40
The order of the elements in the output must be the same as their appearance in the input list.
inputFormat
The input is read from standard input (stdin) and has the following format:
The first line contains an integer (n) denoting the number of elements in the list. The second line contains (n) space-separated integers representing the list. The third line contains two space-separated integers (L) and (H) representing the lower and upper bounds (inclusive) of the range.
outputFormat
Print to standard output (stdout) the filtered elements that lie within the range ([L, H]). The numbers should be printed in the same order as in the input list, separated by a single space. If no elements fit the criteria, output nothing.## sample
7
1 5 8 12 4 18 3
4 10
5 8 4