employer cover photo
employer logo
employer logo

Susquehanna International Group

Engaged Employer

Susquehanna International Group Interview Question

Given two strings, check if you can form the second string using characters in the first one

Interview Answer

Anonymous

Jan 3, 2019

Use a hash table. Iterate over the first string, add characters and their count to the table and then decrease the count while traversing the second string. If we don't get the case where we have to subtract from a zero entry in the table, then we can form the string.