+ 4
String palindrome via alphebetical compression
Given a string consists of multiple alphabets, if its not a palindrome, compress TWO consecutive alphabets by value. a =>1 b=>2 .... The compression may occur more than once, given different situations. If no possible compression can be made, give an appropriate message. For example: baaa should return ba(b) dcad should return d(d)d abab should return (c)(c) jead & js should return not available for dual alphabetical compression Compression resulting in a single alphabet will not be considered.
5 Respostas
+ 3
Bonus: for some special cases, such as jead, will require triple compression where three alphabets are compressed:
jead should be j(j) in this way.
Make the code available for the following examples as well:
abei should return (i)i
acbzdaa should return (f)z(f).
Good Luck, and have fun coding.
+ 3
there are many constraints missing,
baaa => ba ( aa) => ba(b)
started from right end
dcad => d(ca)d => d(d)d
started from middle
acbzdaa => (ac)bzd(aa) => (d) bzd(b) => (db)z(db) => (f)z(f)
started from both ends,
need more clarification
+ 2
Any kind of suggestion is encouraged to enhance this question after moderate consideration.
+ 2
sayan if ba get compressed to c the final string would be caa which isnt a palindrome
+ 1
baaa
its not pal.
why ba didnt get compressed as c????