CGDISH EDITORIAL - DISHES AND INGREDIENTS

binary-search
cgdish
easy
editorial
search
sorting

#1

PROBLEM LINK:


[Practice][1]

Contest

Setter - Aghamarsh V

Editorial - Aghamarsh V


DIFFICULTY :

Easy

PREREQUISITES :

Array Sorting , Binary Search

PROBLEM :

Given an array of ingredients A, we are to find whether a desired dish could be prepared or not.

EXPLANATION :

When the array of ingredients A is given,sort it so that binary search could be implemented later.

As the ingredients of the desired dish are given, they are searched for in the given array of ingredients A. If all the ingredients that are required to prepare a dish are present in the ingredients array A, then the dish could be prepared and we output YES. If any one of the desired ingredient is not present in the array A, the dish is incomplete and hence cannot be prepared. Hence we output NO.

Binary Search is to be applied to search for ingredients in array A, as the number of search operations are very large.

SOLUTION :

Will be updated soon