Ex’Squeeze’ me please

February 17, 2009 at 12:54 pm 1 comment

Write a function:
squeezeString(char *str);

which takes a string of the form – "AAABBBCCCDFF"
and outputs "A3B3C3DF2"

Note that in case a character occurs once like ‘D’ in this case, do not include its character count in the output. This function should be inline, i.e. do not use any extra space.

Lets see who produces the most elegant code!

Advertisements

Entry filed under: Puzzles.

All Correct! Equal chance to both!

1 Comment Add your own

  • 1. romil  |  February 20, 2009 at 9:05 am

    A loop over all characters and maintaining last count and last character as history.
    I am not writing the code 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Blog Stats

  • 4,036 hits

Recent Comments


%d bloggers like this: