Deloitte Interview Question

9 ball Puzzle Problem From GFG