Oracle interview question

Island matrix grid traversal question