GeeksforGeeks » GPuzzles
Sort the deck of cards with 5 different colors
(5 posts)-
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 YELLOWSorted deck:
BLACK BLACK BLUE BLUE WHITE WHITE YELLOW YELLOW RED RED -
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. -
can someone help me ,with the algorithm to this question
thanks -
why blue came before white in sorted form??
-
@ kapil ..Good Analysis
Reply
You must log in to post.