#C9618. Monotonic Number Check
Monotonic Number Check
Monotonic Number Check
Given a positive integer \(n\), determine whether its digits form a monotonic sequence. A sequence of digits \(a_1, a_2, \ldots, a_k\) is called monotonic if and only if it is either non-decreasing (i.e., \(a_1 \le a_2 \le \cdots \le a_k\)) or non-increasing (i.e., \(a_1 \ge a_2 \ge \cdots \ge a_k\)). For example, the number 1234 is monotonic because \(1 \le 2 \le 3 \le 4\), while 1231 is not monotonic because the sequence does not consistently increase or decrease.
inputFormat
A single positive integer (n) is provided as input via standard input (stdin).
outputFormat
Output a single string: "Yes" if the digits of (n) form a monotonic sequence, and "No" otherwise. The output should be written to standard output (stdout).## sample
1234
Yes