Deleting a lucky string
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Today everyone is celebrating Lucky Numbers Day!
One of the traditional activities done on this day is checking various properties of lucky numbers.
You are given a string representing a lucky number \(s\) – it has an odd length and consists only of the characters 4 and 7. In one step, you can choose two identical characters of the string that are not adjacent and delete them. The task is to determine whether it is possible to obtain a string of length 1 as a result of performing an unlimited number of such operations.
Can you handle this task?
Input
The single line contains the string \(s\) – the proposed lucky number.
Output
In a single line, print YES if it is possible to obtain
a string of length 1. Otherwise, print NO.
Constraints
\(1 \le |s| \le 10^5\),
\(s_i \in \{4, 7\}\),
\(s\) has an odd length.
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 7447744 | YES |
| Input (stdin) | Output (stdout) |
|---|---|
| 44777 | NO |
Notes
In the first example, you can obtain a string of length 1 by performing, for example, the following operations:
Delete the first and fourth characters: 44744
Delete the first and last characters: 474
Delete the first and last characters: 7
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|