#C3739. Matching Stock Levels
Matching Stock Levels
Matching Stock Levels
You are given two lists of integers: the current stock levels s and the target stock levels t. In one move, you are allowed to swap any two items in the list s. Determine if it is possible to transform the list s into the list t using any sequence of such swap operations.
Note: Swapping does not change the multiset of elements. Therefore, it is possible to match the stock levels if and only if the multisets of s and t are identical. In mathematical terms, you must check whether
\( \text{sorted}(s) = \text{sorted}(t) \).
inputFormat
The input is read from stdin
and has the following format:
- An integer
N
representing the number of elements in each list. - A line containing
N
space-separated integers representing the current stock levels s. - A line containing
N
space-separated integers representing the target stock levels t.
outputFormat
Output a single line to stdout
containing True
if it is possible to match the stock levels by swapping, and False
otherwise.
5
5 1 3 2 4
3 2 1 5 4
True
</p>