Pergunta de entrevista da empresa Brilliant (CA)

Questions about trees and graphs and one Difficult string manipulation question