My code for count subsequences is failing test cases

Given a string, count the number of distinct subsequences of it ( including empty subsequence ). For the uninformed, A subsequence of a string is a new string which is formed from the original string by deleting some of the characters without disturbing the relative positions of the remaining characters. For example, “AGH” is a subsequence of “ABCDEFGH” while “AHG” is not.

Input Format
First line of input contains an integer ‘t’ denoting number of test cases.
Next t lines contain a string each.

Constraints
1<=t<=100
1<=length of s<=100000
s will contain upper letters only.

Output Format
For each test case ,print ans%1000000007 in a new line each ,where ans is the number of distinct subsequences.
my solution:-https://ide.codingblocks.com/s/260290

hello @015itachiuchiha
image
use mod property in this statement.
(a-b)%mod=(a-b+mod)%mod
so it should be
dp[i]=(dp[i]+dp[i-1]-mp[s[i]]+mod)%mod

use long long in place of int

But why would mod property be required here ? Are the values overflowing long long int ?

Even after using that it’s giving wrong answer .

check ur updated code here-> https://ide.codingblocks.com/s/260307

yeah they are exceeding the range thats why using modulo

Thanks . It’s working.