Check and infer custom alphabet | Meta Interview Question