Placement of characters in the output

Do the characters in the output substring must be in the same order of the string 2

no, the order does not matter here