Pashmak and Flowers

Problem Link:

This problem asks you to find how many ways you can pick 2 flowers from the flower fields. My approach was : get numbers for most beautiful and least beautiful flower, then multiply those numbers. I used map to store the numbers due to the input.

However, there was a problem: it’s possible that the input has only one kind of flower. So you’ll have to count how many ways you can pick 2 flowers using combinations ( nC2 ).

In case if you don’t know how to code combinations, or if you are too lazy, you can see it here :

Leave a Reply

Your email address will not be published. Required fields are marked *