Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 149f90a

Browse files
Create SamAndSubstring.cpp
1 parent e527095 commit 149f90a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*Hackerrank problem "sam and substring"*/
2+
3+
int substrings(string n) {
4+
5+
long long total_sum = n[0]-'0';
6+
long long last_value = n[0] - '0';
7+
8+
for(int i=1; i<n.length(); i++){
9+
last_value = ((last_value*10)+((n[i]-'0')*(i+1)))%1000000007;
10+
total_sum = (total_sum + last_value)%1000000007;
11+
}
12+
return total_sum;
13+
}
14+
15+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /