HashedIn by Deloitte interview question

Algorithm sql database tree