You and a group of campers are participating in an upcoming Hack-A-Thon. You’ve brainstormed ideas for projects and you want to complete and present exactly two projects in the allotted time.

The group has compiled a list of projects represented by an array A, where the number of total projects is N. Each value in the array is the number of minutes M it will take to complete that project. Your calculations for M fall within a range of 1 <= M <= 43800.

You’re a creative bunch and the number of project ideas you came up with is massive. The number of projects N in A is in the range of 100,000 <= L <= 1,000,000. For this reason, you’ll need an efficient algorithm with a better runtime than O(n^2). A nested loop won’t get the results in time for the competition!

Given an array of projects A and the total time of the Hack-A-Thon in minutes T, write a function to find the two projects that can be completed in exactly T minutes. Return the answer in the form of an array where the two projects are given as their index in the project list A. Your team agrees you want to knock out the shortest project first, so the array result should be ordered with a project requiring less time coming before a project requiring more time.

Additional note: For every input, will always be exactly one pair of projects that together equal the time of the Hack-A-Thon. Both T and A[i] (every value in the array) are integers (n % 1 === 0)

Sample Input:

A (array) = [143, 805, 218, 483, 738, 372, 102, 635, 821];

T (min) = 1440

Returns:

[7, 1]

function findHackProjects(array, min) {

// Your code goes here!

}

If you post your solution on this topic, please surround your answer in “spoiler tags” like this

`details=Your title]Your code[/details]`