I am getting wrong ans for 2 test cases :(

Hi @Muskan-Gupta-598128740703036

You are using 1000000000 instead of 1000000007 to do mod. Then your code works fine.

Hope it Helps.

yup thanks !! submitted 100%