Ice Cream Parlor

  • + 0 comments

    Here is my c++ solution, you can watch the explanation here : https://youtu.be/WvLuA-LCsb0

    vector<int> icecreamParlor(int m, vector<int> arr) {
        map<int, int> mp;
        for (int i = 0; i < arr.size(); i++) {
            int complement = m - arr[i];
            if (mp.count(complement)) {
                return {mp[complement] + 1, i + 1};
            }
            mp[arr[i]] = i;
        }
        return {};
    }