Only 2 test cases passed.. What's the issue?
many problem in your code
-
don’t sort the array other order will change and you get wrong ans
-
t should be consider at the end after calculating ans
just return this
return ((ans%mod)*time)%mod; -
your canPaint() has also some issues
check this code i have explained each step here
Modified Code
Yupp thanks I removed the sort function and it workedd
now can i mark this doubt as resolved??