mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 17:34:49 +08:00
Fix sphinx/build_docs warnings for dynamic_programming (#12484)
* Fix sphinx/build_docs warnings for dynamic_programming * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix * Fix * Fix * Fix * Fix * Fix --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -1,24 +1,25 @@
|
||||
"""
|
||||
Question:
|
||||
You are given an array of distinct integers and you have to tell how many
|
||||
different ways of selecting the elements from the array are there such that
|
||||
the sum of chosen elements is equal to the target number tar.
|
||||
You are given an array of distinct integers and you have to tell how many
|
||||
different ways of selecting the elements from the array are there such that
|
||||
the sum of chosen elements is equal to the target number tar.
|
||||
|
||||
Example
|
||||
|
||||
Input:
|
||||
N = 3
|
||||
target = 5
|
||||
array = [1, 2, 5]
|
||||
* N = 3
|
||||
* target = 5
|
||||
* array = [1, 2, 5]
|
||||
|
||||
Output:
|
||||
9
|
||||
9
|
||||
|
||||
Approach:
|
||||
The basic idea is to go over recursively to find the way such that the sum
|
||||
of chosen elements is “tar”. For every element, we have two choices
|
||||
1. Include the element in our set of chosen elements.
|
||||
2. Don't include the element in our set of chosen elements.
|
||||
The basic idea is to go over recursively to find the way such that the sum
|
||||
of chosen elements is `target`. For every element, we have two choices
|
||||
|
||||
1. Include the element in our set of chosen elements.
|
||||
2. Don't include the element in our set of chosen elements.
|
||||
"""
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user