020-005-004
Collections: List Sorting and Shuffling
Hard
Problem Description
Collections: List Sorting and Shuffling
In this problem, you will create a program that reads a list of integers, applies the specified operation using Collections class methods (sort, reverse, max, min), and displays the result to standard output.
Learning Objective: Master Collections utility class methods: sort, reverse, max
Perform operations on number list using Collections class methods.
Input
Line 1: Number of elements
Line 2: Space-separated integers
Line 3: Operation ("sort", "reverse", "max", "min")
Output
Sort: Sorted list
Reverse: Reversed list
Max: Maximum value
Min: Minimum value
Example
Input:
5
3 1 4 1 5
sort
Output:
[1, 1, 3, 4, 5]
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up