We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Similar solution, just make sure you make your programs dynamic so that you have minimilistic hardcoding. I hope you will understand comapring below and your's
why faster and scaleable? Linked list faster than array list, use of else if.
scalable because I haven't specified the hardcoded length for inputs
static List<Integer> compareTriplets(List<Integer> a, List<Integer> b) {
int aWin = 0;
int bWin = 0;
List<Integer> win = new LinkedList<Integer>();
for (int i = 0; i < a.size(); i++) {
if (a.get(i) > b.get(i))
++aWin;
else if (a.get(i) < b.get(i))
++bWin;
}
win.add(aWin);
win.add(bWin);
return win;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Compare the Triplets
You are viewing a single comment's thread. Return to all comments →
Similar solution, just make sure you make your programs dynamic so that you have minimilistic hardcoding. I hope you will understand comapring below and your's
why faster and scaleable? Linked list faster than array list, use of else if.
scalable because I haven't specified the hardcoded length for inputs