Company: Trs_5aug
Difficulty: medium
Colorful Path Maze Problem Description You are given a 2D grid maze of size N x M, where each cell contains a color represented by an integer. Your task is to find the number of distinct paths from the top-left corner (0, 0) to the bottom-right corner (N-1, M-1) such that: You can only move right or down at each step. You cannot revisit any color already present in your current path. In other words, no two cells along a single path can have the same color. Use a function to explore all valid paths and count how many satisfy the color uniqueness condition. Function Description: You need to implement the function countColorfulPaths . The function should take the size of the grid and the grid itself and return the number of valid paths from (0, 0) to (N-1, M-1) as per the above rules. Parameters: N - An integer representing the number of rows in the grid. M - An integer representing the number of columns in the grid. grid - A 2D list of integers of size N x M where each integer denotes a