Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8907839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:01:12+00:00 2026-06-15T03:01:12+00:00

How to compress strings like aaabbbc to a3b3c and decompress the same, without using

  • 0

How to compress strings like “aaabbbc” to “a3b3c” and decompress the same, without using extra memory during processing, primarily in C and also in Java?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:01:13+00:00Added an answer on June 15, 2026 at 3:01 am

    A simple reverse scan does provide a (seemingly) good solution to the encoding part at least. I am doing one scan from right to left and overwriting the portions of the string with the occurrence count.

    char * enc(char * ip)
    {
        int r,op;
        int l=strlen(ip);
        r=l-1;
        char curr;
        op=r;
        int curr_count=1,mod_curr_count;
        while(r>=0)
        {
            curr=ip[r];
    
            while(ip[--r]==curr)
            {
    
                curr_count++;
            }
            if(curr_count!=1)
            {
                while(curr_count)
                {
                mod_curr_count=curr_count%10;
                ip[op--]=(char)(mod_curr_count+48);
                curr_count/=10;
                }
                ip[op--]=curr;
                curr_count=1;
    
            }
            else
            {
            ip[op--]=curr;
            }
        }
    
        ip=ip+op+1;
        return ip;
    }
    

    Input : aaaaaaaaaaaabbbfffffffffffffffqqqqqqqqqqqqqqqqqqccccpoii

    Output: a12b3f15q18c4poi2

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string that I would like to compress using GZip before inserting
I'm searching for an algorithm to compress small text strings: 50-1000 bytes (i.e. URLs).
I have around 2 million strings with different lengths that I need to compress
I'm compressing a string with Gzip using this code: public static String Compress(String decompressed)
I compress my files using this script import pylzma, struct i = open(path+fileName,'rb') o
I need to be able to take a javascript string, compress it using any
I'm trying to compress HTML with JavaScript and decompress it with Ruby. Some carachters
I wanted to write a simple processing function. It should run like this: Load
I have strings that look like this: 000101456890 348324000433 888000033380 They are strings that
I try to compress string in Java like php's gzcompress function does it. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.