Pergunta de entrevista da empresa NVIDIA

Given two strings, find if all the characters from the first string are present in the second string. If the first string has multiple occurrences of the same character, the second string must also have at least those many occurrences of that character

Resposta da entrevista

Sigiloso

17 de abr. de 2012

Use a map to store characters from the second string against the number of times they occur. Run through the first string and decrement the value against each character. If you do not find that character, or if the value against the character is zero, return false