Chubb Interview Question

one recursion question and one question of prefix sum/difference array topic