How to Form Minimum number of Groups which should not exceed a max value
-
I have a datatable like below
Employee Salary
Emp A 1000
Emp B 500
Emp C 3000
Emp D 3000
Emp E 200
Emp F 100
Emp G 200
Emp H 500
Emp I 1450I want minimum number of groups, Sum of Salary in one group should not exceed 5000. So my final output should be like this
Employee Salary Group
Emp A 1000 Group 1
Emp B 500 Group 1
Emp C 3000 Group 1
Emp E 200 Group 1
Emp F 100 Group 1
Emp G 200 Group 1Emp D 3000 Group 2
Emp H 500 Group 2
Emp I 1450 Group 2 -
I have a datatable like below
Employee Salary
Emp A 1000
Emp B 500
Emp C 3000
Emp D 3000
Emp E 200
Emp F 100
Emp G 200
Emp H 500
Emp I 1450I want minimum number of groups, Sum of Salary in one group should not exceed 5000. So my final output should be like this
Employee Salary Group
Emp A 1000 Group 1
Emp B 500 Group 1
Emp C 3000 Group 1
Emp E 200 Group 1
Emp F 100 Group 1
Emp G 200 Group 1Emp D 3000 Group 2
Emp H 500 Group 2
Emp I 1450 Group 2 -
Sorry