Google Code Jam: Store Credit Java Solution
Performance is bad. List.contains() runs in linear time, driving it to quadratic. Recommendation: prepare the list of {price, index} pairs, and stable sort it by prices. The solution is then found in a single scan, along the lines of

    while (head &lt; tail) {
        total = head-&gt;price + tail-&gt;price;
        if (total &lt; credit) {
            ++head;
        else if total &gt; credit) {
            --tail;
        else {
            return {head-&gt;index, tail-&gt;index};
        }
    }