Ejemplo n.º 1
0
  public static void main(String[] args) {
    int[] A = {1, 5, 4, 3, 1, 2, 0, 1};
    int step = new Q39_JumpGame2().jumpMy(A);
    System.out.println(step);
    int step2 = new Q39_JumpGame2().jumpEx(A);
    System.out.println(step2);

    int[] testA = TestUtil.generateArray(999, 50, false);
    long l1 = System.currentTimeMillis();
    int stepa = new Q39_JumpGame2().jumpMy(testA);
    long l2 = System.currentTimeMillis();
    int stepb = new Q39_JumpGame2().jumpEx(testA);
    long l3 = System.currentTimeMillis();
    long span1 = l2 - l1, span2 = l3 - l2;
    System.out.println(stepa + " Cost " + span1);
    System.out.println(stepb + " Cost " + span2);
  }