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.
Sherlock and Probability
Sherlock and Probability
Sort by
recency
|
25 Discussions
|
Please Login in order to post a comment
Same idea as Daniel_v_oconnor, but the code is a little easier to understand.
The trickiest part of this problem is that one must use the "rolling sum" trick to obtain an O(N) solution that meets the runtime requirements. Here's a relatively simple Python solution:
I had to make code use one loop instead of two loops to avoid TLE in test case 0. Just advice for whoever is getting TLE in test case 0 as well.