This problem is like 2 processor job scheduling problem ,We may get an
optimal solution for different instances using different algorithm apart
from brute force.Whereas Brute force covers all possible subsets but may
take years to complete if N is large.
above algo fails in the following example.
@Abhishek,
I think your logic will not work. Although it can be done by greedy
approach, but your method needs some tweak.
Consider the case : 1,2,3,4,5,12
with your logic, we will get this answer
team 1: 1,3,5 (total=9)
team 2: 2,4,12(total=18)
difference is 9 and its huge.
what can be done is af
@abhishek:i meant after sorting split the array into 2 part each with equal
sum
On Sun, May 30, 2010 at 11:45 PM, Abhishek Sharma wrote:
> @sharad: if you find the subarrays of equal sum then the number of players
> might differ in the team... also can you tell me how will you do
> that..acc
Correction: Team2:7, 10, 11, 12, 15
On Sun, May 30, 2010 at 11:45 PM, Abhishek Sharma wrote:
> @sharad: if you find the subarrays of equal sum then the number of players
> might differ in the team... also can you tell me how will you do
> that..according to me time cmoplexity will be higher..
@sharad: if you find the subarrays of equal sum then the number of players
might differ in the team... also can you tell me how will you do
that..according to me time cmoplexity will be higher..
According to me:
sort the palyers based on skill points (O(nlogn) --mergesort) then assign
the players
sort the players based on skill point and get the subarray of equal
sum..
On Sun, May 30, 2010 at 6:58 PM, Veer Sharma wrote:
> Hi Friends,
>
> This is my first post to this forum. A "Hi" to all of you and here is
> my first problem...
>
> Giiven int n, the total number of players and their s
Hi Friends,
This is my first post to this forum. A "Hi" to all of you and here is
my first problem...
Giiven int n, the total number of players and their skill-point.
Distribute the players on 2 evenly balanced teams.
Lets see who gives the best solution (least space complexity / least
time comp