Home > Computer Programming > My Fun Time ;) !

My Fun Time ;) !

Was just sitting in the office at 4:30 P.M when I just read this problem.

“Arrange the letters in a sequence , if there are given letters in a random order as abcbcabcabcabb, we have to arrange them in a sequence means in a fashion of aaaabbbbbcccc(means all the a should come first then all b’s and then all c’s) in O(n) complexity”.

Now thats a very easy problem if i have to solve it for english alphabets. At 4:33 P.M I finished coding it in C++.

P.S: I am able to code so fast as I have always opened a Windows of Visual Studio for C++.

Here is the code I Wrote.

void ArrangeLetters(char input[], int size)

int freq_lett[26] = {0};
char * temp = new char[size+1];
for(int index = 0 ; index
for(int index = 1 ; index
freq_lett[index] = freq_lett[index] + freq_lett[index-1];
for(int index = 0 ; index
temp[(freq_lett[input[index]-97]) -1] = input[index];
temp[size] = ”;
for(int index = 0 ; index
input[index] = temp[index];

Some of you might be thinking about kind of my fun. But believe me there is so much variety of
people in this world that 1 can expect anything from any one. So thats my way of seeing
fun and hitting a solution of any existing small/long but trickier or at times tougher computational problem or algorithm.

99 Zeroes and Google ^ Google!

Categories: Computer Programming
  1. December 24, 2005 at 12:18 am

    Fix Slow Computer Problems with Error Doctor Free Scan!

  1. No trackbacks yet.

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

%d bloggers like this: