Contact me

email: tianrunhe@gmail.com

8 Comments (+add yours?)

  1. thara
    Jul 29, 2012 @ 06:55:50

    Reply

  2. nivetha
    Aug 22, 2012 @ 09:14:50

    i teird this code ..it doesnt show any error.but no output…so pls make a help

    Reply

  3. nivetha
    Aug 22, 2012 @ 09:16:09

    sry this is my code FOR SORT AN ARRAY OF STRINGS SO THAT ANAGRAMS OF EACH POINTS NEXT TO EACH OTHERS

    #include
    #include
    int i,j,table[26],count=8;
    int temp;
    main()
    {
    char a[]={“xyz”,”cab”,”abc”,”yzx”,”ab”,”ca”,”ba”,”ac”};
    // count=sizeof(a)/sizeof(a[0]);
    sortAnagrams(a,count);
    }
    int areAnagrams(char *a1, char *a2) {
    int n1=strlen(a1);
    int n2=strlen(a2);
    if(n1!=n2)
    return 0;

    for ( i = 0; i < n1; ++i) {
    int index = a1[i]-'a';
    table[index]++;
    }
    for (i = 0; i <n2; ++i) {
    int index = a2[i] – 'a';
    if (table[index] <= 0)
    return 0;
    table[index]–;
    }
    for (i = 0; i 0)
    return 0;
    }
    return 1;
    }
    int swap(char *a[], int i, int j) {
    temp = *a[i];
    *a[i] = *a[j];
    *a[j] = temp;
    }

    int sortAnagrams(char *a[],int n) {
    for ( i = 0; i < n- 1; ++i) {
    for ( j = i + 1; j < n; ++j) {
    if (areAnagrams(a[i], a[j]))
    swap(a, i + 1, j);
    }
    }
    }

    Reply

  4. Siva
    Dec 05, 2012 @ 15:36:25

    Great work dude. Please sort the careercup questions as topic slike Arrays, Strings, Stack, Queue, Trees etc etc. It will be easier for us to search.

    Reply

  5. jvishal
    May 23, 2013 @ 07:57:17

    Excellent work !!! I appreciate your efforts.

    Reply

  6. jitingxu
    Jul 22, 2013 @ 10:57:54

    Great Job

    Reply

  7. Virendra
    Jan 02, 2014 @ 23:04:03

    Nice .. Please update your site with more Java and Data Structure Questions.

    Reply

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: