Advotics interview question

Algorithm and data structure. ERD