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.
Project Euler #8: Largest product in a series
Project Euler #8: Largest product in a series
Sort by
recency
|
210 Discussions
|
Please Login in order to post a comment
Okay. I'm improving. This should have taken me atleast an hour. Done it in 20 mins. C# solution
JavaScript solution:
All test cases passed:
def Solve_Prob(n,k,strm): maxi = -1 for i in range(0,n-k+1): pro = 1 for j in range(i,i+k): pro = pro*int(strm[j]) if pro > maxi: maxi = pro answer = maxi return answer
t = int(input()) for i in range(0,t): n,k = list(map(int,input().split())) m = input() answer = Solve_Prob(n,k,m) print(answer)
Javascript
Can someone find whats wrong with my code?
*