Company: Curefit
Difficulty: medium
Count Colorful Paths Problem Description You are given a 2D grid maze of size N x M in which every cell carries a colour, written as an integer. A walker starts at the top-left corner (0, 0) and wants to reach the bottom-right corner (N - 1, M - 1) . From a cell (r, c) the walker may move only right to (r, c + 1) or down to (r + 1, c) . A path is called colorful when no colour repeats anywhere along it: taking the colours of all the cells the path visits, including the starting cell and the ending cell, every one of them must be different. Count how many colorful paths lead from (0, 0) to (N - 1, M - 1) . Function Description Complete the function countColorfulPaths() . It takes the following 3 parameters and returns the answer: n : an integer, the number of rows of the grid. m : an integer, the number of columns of the grid. grid : a 2D integer array of size n x m , where grid[i][j] is the colour of the cell (i, j) . Returns an integer, the number of colorful paths from (0, 0) to (N -