Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Butterfly

By khepa98 · Limits 1s, 512 MB

A string is a butterfly string if it has a 0 at the middle of the string and at both sides of 0 there are exactly the same number of positive length of characters and all the characters are same. For a given string of size, n determine if it is a butterfly string or not.

Input

Input starts with n the size of the string and at the second line, there will be a string of size n consisting of uppercase English letters, lowercase English letters, and digits.

1 ≤ n ≤ 100

Output

If the given string is a butterfly string print “YES” else “NO” ( without quotation signs ) in a single line

Sample

InputOutput
5
YY0YY
YES

    Discussion

    Statistics


    81% Solution Ratio

    Uosmoy383Earliest, 3w ago

    MoRanSky.835291Fastest, 0.0s

    Uosmoy383Lightest, 131 kB

    ADRI0777Shortest, 187B

    Submit

    Login to submit

    Toph uses cookies. By continuing you agree to our Cookie Policy.