A. Constructive Problem banner

A. Constructive Problem

1 devlogs
1h 6m 18s

its a solutions of of a codeforce problem ->https://codeforces.com/problemset/problem/1819/A
u can try this by submiting this code in codeforce through codeforce site , or run locally by inputting the inputs manually.
example input ->
4
3
1 2 1
4
0 2 2 0
4
3 2 0 2
1
0

kuratus89

This code checks each test case array by finding its mex (smallest missing non‑negative integer x). It counts frequencies, then:

If x == n (array is 0..n-1), it says “NO”.
If x+1 is missing or appears exactly once, or if x == 0, it says “YES”.
Otherwise, it simulates removing a contiguous segment that includes at least one x+1, making sure all numbers < x still remain afterward and that x+1 isn’t fully exhausted too early; if this succeeds, it prints “YES”, else “NO”.

Attachment
0