Setter - Aghamarsh V
Editorial - Aghamarsh V
Given an array of ingredients A, we are to find whether a desired dish could be prepared or not.
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.
Setter’s Solution can be found here