ResearchGate interview question

* Write pseudo code for the proposed solution? * What is the complexity of solution?