#K35847. Unique Herb Arrangement
Unique Herb Arrangement
Unique Herb Arrangement
You are given N herbs, each with a certain height. Your task is to determine whether it is possible to arrange these herbs in a row so that no two adjacent herbs have the same height.
Since the only way to ensure that no two adjacent herbs share the same height is that all herbs must be unique, the problem reduces to verifying if all the herbs have distinct heights.
Formally, given a sequence \(a_1, a_2, \dots, a_N\), check whether \(\max_{x \in \{a_1, a_2, \dots, a_N\}}\, count(x) = 1\). If yes, print "Yes"; otherwise, print "No".
inputFormat
The first line contains an integer N (\(1 \le N \le 10^5\)) — the number of herbs.
The second line contains N integers separated by spaces, representing the heights of the herbs. Each height is an integer.
outputFormat
Output a single line with the word "Yes" if it is possible to arrange the herbs such that no two adjacent herbs have the same height, or "No" otherwise.
## sample3
1 2 3
Yes
</p>