Chubb interview question

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