Topcoder SRM 640 div2 250point

this question is very easy!!

start and ribons

if left and right is different counting ++

my code is below~


problem
http://community.topcoder.com/stat?c=problem_statement&pm=13556



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
public class ChristmasTreeDecorationDiv2 {

 public int solve(int[] col, int[] x, int[] y){
  int len = x.length;
  int cnt =0;
  for(int i=0; i<len; i++){
   if(col[x[i]-1] != col[y[i]-1]){
    cnt++;
   }
  }
  return cnt;
 }
}

Comments

Popular posts from this blog

Project euler 169 found clue

Floyd-Warshall's algorithm