We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
vector<int>icecreamParlor(intm,vector<int>arr){vector<int>result;intexpense_left;for(inti=0;i<arr.size();i++){expense_left=m-arr[i];// for every entry, calculate expense leftautosearch=find(arr.begin()+i+1,arr.end(),expense_left);// see if expense left is available//if expense left is available, return 1-based indexif(search!=arr.end()){result.push_back(i+1);result.push_back(search-arr.begin()+1);// search-arr.begin() gives 0-based indexing, so add 1break;}}returnresult;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
C++