Query to find most number of rows with greatest sum
I have a table that is like below, as example
A. 1
B. 2
C. 3
D. 99
E. 90
I need a query that calculates and returns the set of the greatest number of rows that sum to equal or less than 102, for example, choosing the set with the total nearest to the target.
If there are tied results that have the same total and same number of rows then take the set with the highest single value of Accessible
In this example the answer is A,B,D
because that has three items, while C,D
(which also sums to 102) only has two.
sql oracle knapsack-problem subset-sum
|
show 6 more comments
I have a table that is like below, as example
A. 1
B. 2
C. 3
D. 99
E. 90
I need a query that calculates and returns the set of the greatest number of rows that sum to equal or less than 102, for example, choosing the set with the total nearest to the target.
If there are tied results that have the same total and same number of rows then take the set with the highest single value of Accessible
In this example the answer is A,B,D
because that has three items, while C,D
(which also sums to 102) only has two.
sql oracle knapsack-problem subset-sum
2
This question is very hard to understand, you need to clarify your logic for getting the desired output. For instance, why isn’t c,d the answer? Maybe you shouldn’t put your whole explanation of the logic into one sentence
– Joakim Danielson
Nov 25 '18 at 7:54
Given that this is a Knapsack Problem question you will find this blog piece by Brendan P very useful.
– APC
Nov 25 '18 at 8:21
Then describe that in your question, my main point isn’t if c,d or a,b,d is the best solution. My point is that your question is hard to understand.
– Joakim Danielson
Nov 25 '18 at 8:23
1
"value of Accessible": what is that?
– trincot
Nov 25 '18 at 11:22
1
@r.malekmohammadi . . . What version of Oracle are you using?
– Gordon Linoff
Nov 25 '18 at 12:37
|
show 6 more comments
I have a table that is like below, as example
A. 1
B. 2
C. 3
D. 99
E. 90
I need a query that calculates and returns the set of the greatest number of rows that sum to equal or less than 102, for example, choosing the set with the total nearest to the target.
If there are tied results that have the same total and same number of rows then take the set with the highest single value of Accessible
In this example the answer is A,B,D
because that has three items, while C,D
(which also sums to 102) only has two.
sql oracle knapsack-problem subset-sum
I have a table that is like below, as example
A. 1
B. 2
C. 3
D. 99
E. 90
I need a query that calculates and returns the set of the greatest number of rows that sum to equal or less than 102, for example, choosing the set with the total nearest to the target.
If there are tied results that have the same total and same number of rows then take the set with the highest single value of Accessible
In this example the answer is A,B,D
because that has three items, while C,D
(which also sums to 102) only has two.
sql oracle knapsack-problem subset-sum
sql oracle knapsack-problem subset-sum
edited Nov 25 '18 at 13:10
trincot
125k1588121
125k1588121
asked Nov 25 '18 at 7:19
r.malekmohammadir.malekmohammadi
141
141
2
This question is very hard to understand, you need to clarify your logic for getting the desired output. For instance, why isn’t c,d the answer? Maybe you shouldn’t put your whole explanation of the logic into one sentence
– Joakim Danielson
Nov 25 '18 at 7:54
Given that this is a Knapsack Problem question you will find this blog piece by Brendan P very useful.
– APC
Nov 25 '18 at 8:21
Then describe that in your question, my main point isn’t if c,d or a,b,d is the best solution. My point is that your question is hard to understand.
– Joakim Danielson
Nov 25 '18 at 8:23
1
"value of Accessible": what is that?
– trincot
Nov 25 '18 at 11:22
1
@r.malekmohammadi . . . What version of Oracle are you using?
– Gordon Linoff
Nov 25 '18 at 12:37
|
show 6 more comments
2
This question is very hard to understand, you need to clarify your logic for getting the desired output. For instance, why isn’t c,d the answer? Maybe you shouldn’t put your whole explanation of the logic into one sentence
– Joakim Danielson
Nov 25 '18 at 7:54
Given that this is a Knapsack Problem question you will find this blog piece by Brendan P very useful.
– APC
Nov 25 '18 at 8:21
Then describe that in your question, my main point isn’t if c,d or a,b,d is the best solution. My point is that your question is hard to understand.
– Joakim Danielson
Nov 25 '18 at 8:23
1
"value of Accessible": what is that?
– trincot
Nov 25 '18 at 11:22
1
@r.malekmohammadi . . . What version of Oracle are you using?
– Gordon Linoff
Nov 25 '18 at 12:37
2
2
This question is very hard to understand, you need to clarify your logic for getting the desired output. For instance, why isn’t c,d the answer? Maybe you shouldn’t put your whole explanation of the logic into one sentence
– Joakim Danielson
Nov 25 '18 at 7:54
This question is very hard to understand, you need to clarify your logic for getting the desired output. For instance, why isn’t c,d the answer? Maybe you shouldn’t put your whole explanation of the logic into one sentence
– Joakim Danielson
Nov 25 '18 at 7:54
Given that this is a Knapsack Problem question you will find this blog piece by Brendan P very useful.
– APC
Nov 25 '18 at 8:21
Given that this is a Knapsack Problem question you will find this blog piece by Brendan P very useful.
– APC
Nov 25 '18 at 8:21
Then describe that in your question, my main point isn’t if c,d or a,b,d is the best solution. My point is that your question is hard to understand.
– Joakim Danielson
Nov 25 '18 at 8:23
Then describe that in your question, my main point isn’t if c,d or a,b,d is the best solution. My point is that your question is hard to understand.
– Joakim Danielson
Nov 25 '18 at 8:23
1
1
"value of Accessible": what is that?
– trincot
Nov 25 '18 at 11:22
"value of Accessible": what is that?
– trincot
Nov 25 '18 at 11:22
1
1
@r.malekmohammadi . . . What version of Oracle are you using?
– Gordon Linoff
Nov 25 '18 at 12:37
@r.malekmohammadi . . . What version of Oracle are you using?
– Gordon Linoff
Nov 25 '18 at 12:37
|
show 6 more comments
2 Answers
2
active
oldest
votes
You could use a recursive query, but as this is a non-polynomial problem, the performance will degrade with more records. The first with
query is just generating the sample data. In your case you would of course query your actual table:
with tbl(key, value) as (
select 'A', 1 from dual union all
select 'B', 2 from dual union all
select 'C', 3 from dual union all
select 'D', 99 from dual union all
select 'E', 90 from dual
),
rec(greatest_key, greatest_single, key_count, keys, total) as (
select key,
value,
1,
key,
value
from tbl
union all
select tbl.key,
greatest(tbl.value, rec.greatest_single),
rec.key_count+1,
substr(rec.keys, 0, 1000) || ', ' || tbl.key,
rec.total + tbl.value
from rec
inner join tbl
on tbl.key > rec.greatest_key
and rec.total + tbl.value <= 102
),
ordered(total, keys, r) as (
select total, keys, row_number() over (
order by total desc, key_count desc, greatest_single desc)
from rec
)
select total, keys
from ordered
where r = 1
The ordered
part is only there to get the "top" record.
See it run on rextester.
If you have Oracle 12c+ you can end the query without using ordered
:
select total, keys
from rec
order by total desc,
key_count desc
OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY
Does this answer your question? Any feed-back?
– trincot
Nov 25 '18 at 19:30
add a comment |
Here is my attempt. NOT TESTED.
FUNCTION find_min_set ( p_target IN NUMBER ) RETURN VARCHAR2 IS
CURSOR c1 ( p_find_val NUMBER ) IS
SELECT the_id, the_val
FROM the_table t1
WHERE the_val = ( SELECT MAX( the_val ) the_val
FROM the_table
WHERE the_val <= p_find_val ) ;
l_target NUMBER;
l_id VARCHAR2(16);
l_val NUMBER;
l_ret_List VARCHAR2(4000) := '';
BEGIN
l_target := p_target;
WHILE l_target > 0 LOOP
OPEN c1 ( l_target );
FETCH c1 INTO l_id, l_val;
EXIT WHEN c1%NOTFOUND;
CLOSE c1;
l_ret_list := l_ret_list || ' ' || l_id;
l_target := l_target - l_val;
END LOOP;
l_ret_list := 'Target: ' || p_target || ',' ||
'Remaidner: ' || l_target || ', ' ||
'List: ' || l_ret_list;
RETURN ( l_ret_list );
END;
/
The query returns the col with the largest value <= the target.
The returned value is subtracted from the target and we serach again for teh largest value <= the new target.
We repeat this until the new target is 0 (original tager has been reached) or theer are no more values <= target.
Form teh results as required and return.
1
Starting with the largest single value will produce a suboptimal answer. For instance, give the OP's example it will alight onD, C
rather thatD, B, A
. Given that this is a knapsack problem, it can only be adequately solved with a recursive/combinatorial approach.
– APC
Nov 25 '18 at 11:26
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53465461%2fquery-to-find-most-number-of-rows-with-greatest-sum%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could use a recursive query, but as this is a non-polynomial problem, the performance will degrade with more records. The first with
query is just generating the sample data. In your case you would of course query your actual table:
with tbl(key, value) as (
select 'A', 1 from dual union all
select 'B', 2 from dual union all
select 'C', 3 from dual union all
select 'D', 99 from dual union all
select 'E', 90 from dual
),
rec(greatest_key, greatest_single, key_count, keys, total) as (
select key,
value,
1,
key,
value
from tbl
union all
select tbl.key,
greatest(tbl.value, rec.greatest_single),
rec.key_count+1,
substr(rec.keys, 0, 1000) || ', ' || tbl.key,
rec.total + tbl.value
from rec
inner join tbl
on tbl.key > rec.greatest_key
and rec.total + tbl.value <= 102
),
ordered(total, keys, r) as (
select total, keys, row_number() over (
order by total desc, key_count desc, greatest_single desc)
from rec
)
select total, keys
from ordered
where r = 1
The ordered
part is only there to get the "top" record.
See it run on rextester.
If you have Oracle 12c+ you can end the query without using ordered
:
select total, keys
from rec
order by total desc,
key_count desc
OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY
Does this answer your question? Any feed-back?
– trincot
Nov 25 '18 at 19:30
add a comment |
You could use a recursive query, but as this is a non-polynomial problem, the performance will degrade with more records. The first with
query is just generating the sample data. In your case you would of course query your actual table:
with tbl(key, value) as (
select 'A', 1 from dual union all
select 'B', 2 from dual union all
select 'C', 3 from dual union all
select 'D', 99 from dual union all
select 'E', 90 from dual
),
rec(greatest_key, greatest_single, key_count, keys, total) as (
select key,
value,
1,
key,
value
from tbl
union all
select tbl.key,
greatest(tbl.value, rec.greatest_single),
rec.key_count+1,
substr(rec.keys, 0, 1000) || ', ' || tbl.key,
rec.total + tbl.value
from rec
inner join tbl
on tbl.key > rec.greatest_key
and rec.total + tbl.value <= 102
),
ordered(total, keys, r) as (
select total, keys, row_number() over (
order by total desc, key_count desc, greatest_single desc)
from rec
)
select total, keys
from ordered
where r = 1
The ordered
part is only there to get the "top" record.
See it run on rextester.
If you have Oracle 12c+ you can end the query without using ordered
:
select total, keys
from rec
order by total desc,
key_count desc
OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY
Does this answer your question? Any feed-back?
– trincot
Nov 25 '18 at 19:30
add a comment |
You could use a recursive query, but as this is a non-polynomial problem, the performance will degrade with more records. The first with
query is just generating the sample data. In your case you would of course query your actual table:
with tbl(key, value) as (
select 'A', 1 from dual union all
select 'B', 2 from dual union all
select 'C', 3 from dual union all
select 'D', 99 from dual union all
select 'E', 90 from dual
),
rec(greatest_key, greatest_single, key_count, keys, total) as (
select key,
value,
1,
key,
value
from tbl
union all
select tbl.key,
greatest(tbl.value, rec.greatest_single),
rec.key_count+1,
substr(rec.keys, 0, 1000) || ', ' || tbl.key,
rec.total + tbl.value
from rec
inner join tbl
on tbl.key > rec.greatest_key
and rec.total + tbl.value <= 102
),
ordered(total, keys, r) as (
select total, keys, row_number() over (
order by total desc, key_count desc, greatest_single desc)
from rec
)
select total, keys
from ordered
where r = 1
The ordered
part is only there to get the "top" record.
See it run on rextester.
If you have Oracle 12c+ you can end the query without using ordered
:
select total, keys
from rec
order by total desc,
key_count desc
OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY
You could use a recursive query, but as this is a non-polynomial problem, the performance will degrade with more records. The first with
query is just generating the sample data. In your case you would of course query your actual table:
with tbl(key, value) as (
select 'A', 1 from dual union all
select 'B', 2 from dual union all
select 'C', 3 from dual union all
select 'D', 99 from dual union all
select 'E', 90 from dual
),
rec(greatest_key, greatest_single, key_count, keys, total) as (
select key,
value,
1,
key,
value
from tbl
union all
select tbl.key,
greatest(tbl.value, rec.greatest_single),
rec.key_count+1,
substr(rec.keys, 0, 1000) || ', ' || tbl.key,
rec.total + tbl.value
from rec
inner join tbl
on tbl.key > rec.greatest_key
and rec.total + tbl.value <= 102
),
ordered(total, keys, r) as (
select total, keys, row_number() over (
order by total desc, key_count desc, greatest_single desc)
from rec
)
select total, keys
from ordered
where r = 1
The ordered
part is only there to get the "top" record.
See it run on rextester.
If you have Oracle 12c+ you can end the query without using ordered
:
select total, keys
from rec
order by total desc,
key_count desc
OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY
edited Nov 25 '18 at 13:13
answered Nov 25 '18 at 12:49
trincottrincot
125k1588121
125k1588121
Does this answer your question? Any feed-back?
– trincot
Nov 25 '18 at 19:30
add a comment |
Does this answer your question? Any feed-back?
– trincot
Nov 25 '18 at 19:30
Does this answer your question? Any feed-back?
– trincot
Nov 25 '18 at 19:30
Does this answer your question? Any feed-back?
– trincot
Nov 25 '18 at 19:30
add a comment |
Here is my attempt. NOT TESTED.
FUNCTION find_min_set ( p_target IN NUMBER ) RETURN VARCHAR2 IS
CURSOR c1 ( p_find_val NUMBER ) IS
SELECT the_id, the_val
FROM the_table t1
WHERE the_val = ( SELECT MAX( the_val ) the_val
FROM the_table
WHERE the_val <= p_find_val ) ;
l_target NUMBER;
l_id VARCHAR2(16);
l_val NUMBER;
l_ret_List VARCHAR2(4000) := '';
BEGIN
l_target := p_target;
WHILE l_target > 0 LOOP
OPEN c1 ( l_target );
FETCH c1 INTO l_id, l_val;
EXIT WHEN c1%NOTFOUND;
CLOSE c1;
l_ret_list := l_ret_list || ' ' || l_id;
l_target := l_target - l_val;
END LOOP;
l_ret_list := 'Target: ' || p_target || ',' ||
'Remaidner: ' || l_target || ', ' ||
'List: ' || l_ret_list;
RETURN ( l_ret_list );
END;
/
The query returns the col with the largest value <= the target.
The returned value is subtracted from the target and we serach again for teh largest value <= the new target.
We repeat this until the new target is 0 (original tager has been reached) or theer are no more values <= target.
Form teh results as required and return.
1
Starting with the largest single value will produce a suboptimal answer. For instance, give the OP's example it will alight onD, C
rather thatD, B, A
. Given that this is a knapsack problem, it can only be adequately solved with a recursive/combinatorial approach.
– APC
Nov 25 '18 at 11:26
add a comment |
Here is my attempt. NOT TESTED.
FUNCTION find_min_set ( p_target IN NUMBER ) RETURN VARCHAR2 IS
CURSOR c1 ( p_find_val NUMBER ) IS
SELECT the_id, the_val
FROM the_table t1
WHERE the_val = ( SELECT MAX( the_val ) the_val
FROM the_table
WHERE the_val <= p_find_val ) ;
l_target NUMBER;
l_id VARCHAR2(16);
l_val NUMBER;
l_ret_List VARCHAR2(4000) := '';
BEGIN
l_target := p_target;
WHILE l_target > 0 LOOP
OPEN c1 ( l_target );
FETCH c1 INTO l_id, l_val;
EXIT WHEN c1%NOTFOUND;
CLOSE c1;
l_ret_list := l_ret_list || ' ' || l_id;
l_target := l_target - l_val;
END LOOP;
l_ret_list := 'Target: ' || p_target || ',' ||
'Remaidner: ' || l_target || ', ' ||
'List: ' || l_ret_list;
RETURN ( l_ret_list );
END;
/
The query returns the col with the largest value <= the target.
The returned value is subtracted from the target and we serach again for teh largest value <= the new target.
We repeat this until the new target is 0 (original tager has been reached) or theer are no more values <= target.
Form teh results as required and return.
1
Starting with the largest single value will produce a suboptimal answer. For instance, give the OP's example it will alight onD, C
rather thatD, B, A
. Given that this is a knapsack problem, it can only be adequately solved with a recursive/combinatorial approach.
– APC
Nov 25 '18 at 11:26
add a comment |
Here is my attempt. NOT TESTED.
FUNCTION find_min_set ( p_target IN NUMBER ) RETURN VARCHAR2 IS
CURSOR c1 ( p_find_val NUMBER ) IS
SELECT the_id, the_val
FROM the_table t1
WHERE the_val = ( SELECT MAX( the_val ) the_val
FROM the_table
WHERE the_val <= p_find_val ) ;
l_target NUMBER;
l_id VARCHAR2(16);
l_val NUMBER;
l_ret_List VARCHAR2(4000) := '';
BEGIN
l_target := p_target;
WHILE l_target > 0 LOOP
OPEN c1 ( l_target );
FETCH c1 INTO l_id, l_val;
EXIT WHEN c1%NOTFOUND;
CLOSE c1;
l_ret_list := l_ret_list || ' ' || l_id;
l_target := l_target - l_val;
END LOOP;
l_ret_list := 'Target: ' || p_target || ',' ||
'Remaidner: ' || l_target || ', ' ||
'List: ' || l_ret_list;
RETURN ( l_ret_list );
END;
/
The query returns the col with the largest value <= the target.
The returned value is subtracted from the target and we serach again for teh largest value <= the new target.
We repeat this until the new target is 0 (original tager has been reached) or theer are no more values <= target.
Form teh results as required and return.
Here is my attempt. NOT TESTED.
FUNCTION find_min_set ( p_target IN NUMBER ) RETURN VARCHAR2 IS
CURSOR c1 ( p_find_val NUMBER ) IS
SELECT the_id, the_val
FROM the_table t1
WHERE the_val = ( SELECT MAX( the_val ) the_val
FROM the_table
WHERE the_val <= p_find_val ) ;
l_target NUMBER;
l_id VARCHAR2(16);
l_val NUMBER;
l_ret_List VARCHAR2(4000) := '';
BEGIN
l_target := p_target;
WHILE l_target > 0 LOOP
OPEN c1 ( l_target );
FETCH c1 INTO l_id, l_val;
EXIT WHEN c1%NOTFOUND;
CLOSE c1;
l_ret_list := l_ret_list || ' ' || l_id;
l_target := l_target - l_val;
END LOOP;
l_ret_list := 'Target: ' || p_target || ',' ||
'Remaidner: ' || l_target || ', ' ||
'List: ' || l_ret_list;
RETURN ( l_ret_list );
END;
/
The query returns the col with the largest value <= the target.
The returned value is subtracted from the target and we serach again for teh largest value <= the new target.
We repeat this until the new target is 0 (original tager has been reached) or theer are no more values <= target.
Form teh results as required and return.
edited Nov 25 '18 at 11:26
APC
119k15118229
119k15118229
answered Nov 25 '18 at 10:23
TenGTenG
2,18321324
2,18321324
1
Starting with the largest single value will produce a suboptimal answer. For instance, give the OP's example it will alight onD, C
rather thatD, B, A
. Given that this is a knapsack problem, it can only be adequately solved with a recursive/combinatorial approach.
– APC
Nov 25 '18 at 11:26
add a comment |
1
Starting with the largest single value will produce a suboptimal answer. For instance, give the OP's example it will alight onD, C
rather thatD, B, A
. Given that this is a knapsack problem, it can only be adequately solved with a recursive/combinatorial approach.
– APC
Nov 25 '18 at 11:26
1
1
Starting with the largest single value will produce a suboptimal answer. For instance, give the OP's example it will alight on
D, C
rather that D, B, A
. Given that this is a knapsack problem, it can only be adequately solved with a recursive/combinatorial approach.– APC
Nov 25 '18 at 11:26
Starting with the largest single value will produce a suboptimal answer. For instance, give the OP's example it will alight on
D, C
rather that D, B, A
. Given that this is a knapsack problem, it can only be adequately solved with a recursive/combinatorial approach.– APC
Nov 25 '18 at 11:26
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53465461%2fquery-to-find-most-number-of-rows-with-greatest-sum%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
This question is very hard to understand, you need to clarify your logic for getting the desired output. For instance, why isn’t c,d the answer? Maybe you shouldn’t put your whole explanation of the logic into one sentence
– Joakim Danielson
Nov 25 '18 at 7:54
Given that this is a Knapsack Problem question you will find this blog piece by Brendan P very useful.
– APC
Nov 25 '18 at 8:21
Then describe that in your question, my main point isn’t if c,d or a,b,d is the best solution. My point is that your question is hard to understand.
– Joakim Danielson
Nov 25 '18 at 8:23
1
"value of Accessible": what is that?
– trincot
Nov 25 '18 at 11:22
1
@r.malekmohammadi . . . What version of Oracle are you using?
– Gordon Linoff
Nov 25 '18 at 12:37