Oracle interview question

hardest problem ever done and implement it using classes