Sunday, November 9, 2014

SRM 637 Div 2 250-pt

Problem
http://community.topcoder.com/stat?c=problem_statement&pm=13505&rd=16080

You're given two int[] with the same length. Count the number of times the second int[] has a larger value at i than the first int[].

Code
public int calc(int[] snuke, int[] sothe)
{
int win = 0;
for(int i = 0; i < snuke.Length; i++)
{
if (snuke[i] > sothe[i])
win++;
}
return win;

}

Analysis
O(n) where n is the length of the arrays. 

No comments:

Post a Comment

There was an error in this gadget