GeeksforGeeks » GPuzzles

Sort the deck of cards with 5 different colors

(5 posts)

Tags:

  1. Rahul Naik
    guest
    Posted 1 year ago #

    Perform the in-place sort on a deck of cards with 5 different colors. Deck having n number of cards and we don't know the exact number of cards of each color.

    e.g Lets desk having sequence of card as

    Original deck:
    BLACK WHITE BLUE RED BLUE WHITE YELLOW RED BLACK YELLOW

    Sorted deck:
    BLACK BLACK BLUE BLUE WHITE WHITE YELLOW YELLOW RED RED

  2. kapil
    guest
    Posted 1 year ago #

    1) Count the number of each card type. Let counts be a, b, c, d and e respectively.
    2) Place a back cards, then b blue cards, c white cards, d yellow cards and e red cards.

  3. seeker7
    Member
    Posted 11 months ago #

    can someone help me ,with the algorithm to this question
    thanks

  4. vivek
    guest
    Posted 10 months ago #

    why blue came before white in sorted form??

  5. WgpShashank
    guest
    Posted 10 months ago #

    @ kapil ..Good Analysis


Reply

You must log in to post.

RSS feed for this topic