Java Problem/Program
<p>Given a string of characters as input, without using regular expression or pattern matching, how to get the output, if the characters matches aaa should output 1 and if the characters matches aBa should output 2. (Note: Should not re-process characters so as to output both “1” and “2” when processing the same input)</p>

<p>So for example:</p>

<p>given 'aaBaBaaaBaaa' it should output 211</p>

<p>given 'aaaBaBaaaaBBaBaBa' it should output 1212</p>

<p>Thanks in advance.</p>

<p>PS: I have posted the same problem for a solution in Ruby at <a href="http://stackoverflow.com/questions/2022436/ruby-program-problem">http://stackoverflow.com/questions/2022436/ruby-program-problem</a>
which might give some insight about the implementation.</p>
