10067

 

10047

 

1645

 

11340

 

1636

Probability: Probability of survival without spin = (total number of adjacent pair of zeros)/(total number of empty + bullets ); Probability of survival with spin/rotation = (total number of zeros)/(total number of empty + bullets ); SO, P_s_without_spin = total adjacent zero/length; P_s_with_spin  = total zero/length; if(P_s_without_spin == P_s_with_spin) total adjacent zero/length = P_s_with_spin  =

1644

 

10679

This problem also can be solved using Suffix array but gets TLE. Code as follows:

 

Pattern Search Problem

There are several algorithm to solve pattern search from a provided string problem. To solve such problem using Naive method(for all the char of the provided string check whether the pattern  contains or not ). It takes O(m*n),here m = string length of pattern and n= string length of the text. There are several algorithm to solve