GOODPREF -Editorial

Commented codes are always appreciated. :slight_smile: . Upvote gives 10 karma. Will give 15 more if you properly document it :slight_smile:

Ask yourself 3 questions.

  1. If freq(‘a’)\neq freq(‘b’) , what is the minimum change in contribution of next appendation w.r.t. first one?
  2. What is the largest possible length of original string S?
  3. How many appendations will it take for all future appendations to reach |S| or 0, provided that the contribution behaves monotonically (eg if increasing, always increase and vice cersa).
1 Like

i also did it with binary search CodeChef: Practical coding for everyone

Good job :slight_smile:

Refer to O(|S|) solution for now. While trying to explain, I noticed @admin linked the wrong solution there. She linked the O({S}^{2}) solution there, I will get that fixed. Sorry for the inconvenience :frowning:

Really interesting question and a really interesting and thought provoking approach.