Posts

Showing posts from April, 2018

GOODPREF Unofficial Editorial(April Long)

PROBLEM LINK: Div1 Div2 Editorialist:- Vikram Jeet Shyoran DIFFICULTY: Easy PREREQUISITES: None PROBLEM: Given a string s and an integer n, full string S is concatenating string s n times. Find the number of non_empty prefixes of t in which the number of occurrences of 'a' is strictly greater than the number of occurrences of 'b'. EXPLANATION: string S= whole string after concatenating n times string s string s = Given string int ans=  number of non_empty prefixes of t in which the number of occurrences of 'a' is strictly  greater than the number of occurrences of 'b' int temp= ans in s let x = count of character 'a' in s       y= count of character 'b' in s Here  we have 3 cases in keeping in mind x and y :- 1) x=y 2)x>y 3)x<y let's do the analysis for each case:- Case # 1: When x=y if n=1 , ans=temp if n=2 , ans= 2*temp if n=3, ans= 3*temp .... ...