Two test cases are going wrong
Hello @Mudit809 you can use set instead of map because all the elements are distinct.
Also you were not using the correct value of max so i corrected it and you need to use modulus in when you are adding the subarrays in ans variable .
Here is the corrected code with some comments .
Please mark the doubt as resolved if it is resolved and rate me accordingly . Thanks 