Wednesday, May 11, 2016

Cross Bridge in minimum time in codefights

This is veryintersting and I just worte down some testcases and
found algorithm.
someday I will write detail of this problem.

my code is here
 int c, l;
 int Bridge(int[] t) {
  while(l>3) {
   c+= Math.min( 2*t[1],  t[l - 2] + t[0]) + t[l-1] + t[0];
  return c+= l<3?t[l-1]:t[1] + t[0]+t[2];

No comments:

Post a Comment