Sam and substrings Discussions | Algorithms | HackerRank
We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
My code:
def substrings(n):
arr=[int(x) for x in n]
_sum=0
for i in range(len(arr)):
print(arr[i])
for k in range(len(arr)-i, 0, -1):
_sum+=_mod(arr[i]10*(k-1)*(i+1))
return _mod(_sum)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sam and substrings
You are viewing a single comment's thread. Return to all comments →
My code: def substrings(n): arr=[int(x) for x in n] _sum=0 for i in range(len(arr)): print(arr[i]) for k in range(len(arr)-i, 0, -1): _sum+=_mod(arr[i]10*(k-1)*(i+1)) return _mod(_sum)