would the interviewer accept this two line solution in C++?


  • 1
    Y

    no use of + or -

        int getSum(int a, int b) {
            vector<int> v = {a, b};
            return accumulate(begin(v), end(v), 0);
        }
    

  • 0

    @yi-shaun Of course, but this can only be a choice and I think he or she will require you to handle it in another more manual way. Clever idea here!


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.