Finding all possible combinations of numbers to reach a given sum

前端 未结 30 3039
一个人的身影
一个人的身影 2020-11-21 06:39

How would you go about testing all possible combinations of additions from a given set N of numbers so they add up to a given final number?

A brief exam

30条回答
  •  情深已故
    2020-11-21 06:58

    Thank you.. ephemient
    

    i have converted above logic from python to php..

    0;$i--)
      {
        if($res[$i]!=0)
        {
            return $res[$i];
            break;
        }
      }
    return array();
    }
    ?>
    

提交回复
热议问题