Oracle Interview Question

hardest problem ever done and implement it using classes