Unsure on how to implement mod 10^9 +7

I’m sure I have implemented the logic properly as it works on all sample test cases but I’ve messed up in the modular arithmetic logic for it. Can I please have help with the modular arithmetic logic?

ur code ACfied

1 Like

A wonderful guide to modular arithmetic

1 Like

Thank you so much this was a very stupid oversight on my part