syc0's blog

By syc0, 11 years ago, In English
  • Vote: I like it
  • -8
  • Vote: I do not like it

»
11 years ago, # |
  Vote: I like it 0 Vote: I do not like it

As string length is not large enough and stated in comments, normal recursion solution passes, you can try every possibility(just make sure whenever you find any invalid string, quit trying it at that time only).

For any string character try two possibility : 1. To include it in current group only. 2. Start a new group with it.(Do this only, when current_group_sum is >= last_group_sum, otherwise this will produce an invalid string).