Deloitte interview question

9 ball Puzzle Problem From GFG