Find all pairs of integers within an array which sum to a specified value

前端 未结 15 2033
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 08:00

Design an algorithm to find all pairs of integers within an array which sum to a specified value.

I have tried this problem using a hash

15条回答
  •  半阙折子戏
    2020-12-01 08:50

    We can use C++ STL map to solve this

    void subsetSum(int arr[], int n, int sum)
    {
        mapMap;
    
        for(int i=0; i

提交回复
热议问题