If the difference between any two consecutive elements of the prefix array is greater than 1 then there will be no such string possible that satisfies the given array . Also , string cannot have more than 26 distinct characters
if ( diff > 1 or diff < 0 or A [ i ] > 26 ) : NEW_LINE INDENT S = " - 1" NEW_LINE return S NEW_LINE DEDENT