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?
Labels:Data
Amazon Interview
Subscribe to:
Post Comments
(
Atom
)
4 comments :
answer :: 1
@Jaideep ..Can You Explain the algorothm or logic on the basis u answered ?
Jaldeep's answer is wrong:
try sequence:
abbbc
I believe correct answer is first comment on:
http://www.careercup.com/question?id=11534280
@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 :)
Post a Comment