• + 0 comments

    I got 100 points using pyhton 3. Some optimizations:

    1. The number of pairs that can be formed using the value 1 in the array is known. We don't have to try to calculate the number of pairs with 1's, there is a simple formula for getting the number of all the pairs that contain 1
    2. I created and kept track of a list of ranges which told how many pairs can be generated with the next value in the array.
    3. The number of ranges for some of the tests were probably going up significantly so I got timeout failures, then I switched to binary search to find the range that the value falls in.