About Me

Saturday, November 19, 2011

Given a string consisting of a,b and c's, we can perform the following operation: Take any two adjacent distinct characters and replace it with the third character. For example, if 'a' and 'c' are adjacent, they can replaced with 'b'. What is the smallest string which can result by applying this operation repeatedly?


4 comments:

  1. @Jaideep ..Can You Explain the algorothm or logic on the basis u answered ?

    ReplyDelete
  2. Jaldeep's answer is wrong:

    try sequence:

    abbbc

    I believe correct answer is first comment on:

    http://www.careercup.com/question?id=11534280

    ReplyDelete
  3. @anon ..answer suggested by ashish is pretty much correct , also small correction pointed out by me , a guy czpete425 while anon given correctness of algorithm , dats pretty good explanation :)

    ReplyDelete

Hi thanks , we will get back to you shortly !!!