HashedIn by Deloitte interview question

Question from string and b tree