Compare the Triplets

https://www.hackerrank.com/challenges/compare-the-triplets/problem

    public static List<Integer> compareTriplets(List<Integer> a, List<Integer> b) {
    // Write your code here
        List<Integer> out = new ArrayList<Integer>(2);
        out.add(0);
        out.add(0);
        for (int i = 0; i < a.size(); i++) {
            if (a.get(i) > b.get(i))
                out.set(0, out.get(0) + 1);
            else if (a.get(i) < b.get(i))
                out.set(1, out.get(1) + 1);
        }

        return out;
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s