@@ -0,0 +1,2330 @@
+//https://www.hackerrank.com/challenges/the-quickest-way-up%0Aimport java.io.*;%0Aimport java.util.*;%0A%0Apublic class Solution %7B%0A  private final static byte MAX_ROLL = 6;%0A  private final static byte BOARD_LEN = 100;%0A%0A  public static void main(String%5B%5D args) throws IOException %7B%0A    final StringBuffer sb = new StringBuffer();%0A    final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));%0A%0A    //For every test case%0A    for(byte T = Byte.parseByte(br.readLine()); T %3E 0; --T)%7B%0A%0A      //Initialize board%0A      final byte%5B%5D board = new byte%5BBOARD_LEN%5D;%0A      for(byte i = 0; i %3C BOARD_LEN; ++i)%7B%0A        board%5Bi%5D = i;%0A      %7D%0A%0A      //Get snakes%0A      final byte N = Byte.parseByte(br.readLine());%0A      for(byte i = 0; i %3C N; ++i)%7B%0A        final String%5B%5D line = br.readLine().split(%22 %22);%0A        final byte S = (byte)(Byte.parseByte(line%5B0%5D) - 1);%0A        final byte E = (byte)(Byte.parseByte(line%5B1%5D) - 1);%0A        board%5BS%5D = E;%0A      %7D%0A%0A      //Get ladders%0A      final byte M = Byte.parseByte(br.readLine());%0A      for(byte i = 0; i %3C M; ++i)%7B%0A        final String%5B%5D line = br.readLine().split(%22 %22);%0A        final byte S = (byte)(Byte.parseByte(line%5B0%5D) - 1);%0A        final byte E = (byte)(Byte.parseByte(line%5B1%5D) - 1);%0A        board%5BS%5D = E;%0A      %7D%0A%0A%0A      //Solve and print output%0A      sb.append(getMinMoves(board) + %22%5Cn%22);%0A    %7D%0A    System.out.print(sb);%0A  %7D%0A%0A  private static byte getMinMoves(final byte%5B%5D board)%7B%0A%0A    //Initialize moves counting%0A    final byte%5B%5D moves = new byte%5BBOARD_LEN%5D;%0A    for(byte i = 1; i %3C BOARD_LEN; moves%5Bi++%5D = BOARD_LEN)%7B%7D%0A    final Queue%3CByte%3E q = new PriorityQueue%3CByte%3E(new Comparator%3CByte%3E()%7B%0A      @Override%0A      public int compare(Byte a, Byte b)%7B%0A        return b.compareTo(a);%0A      %7D%0A    %7D);%0A%0A    //Go through board and find min moves%0A    q.add((byte)0);%0A    do%7B%0A      final byte square = q.poll();%0A      final byte numMoves = (byte)(moves%5Bsquare%5D + 1);%0A      for(byte i = (byte)(square + 1), n = (byte)(Math.min(BOARD_LEN, i + MAX_ROLL)); i %3C n; ++i)%7B%0A        final byte j = board%5Bi%5D;%0A        if(numMoves %3C moves%5Bj%5D)%7B%0A          moves%5Bj%5D = numMoves;%0A          q.add(j);%0A        %7D%0A      %7D%0A    %7D while (!q.isEmpty());%0A%0A    //Check if possible to reach max square%0A    final byte minMoves = moves%5BBOARD_LEN - 1%5D;%0A    return (minMoves == BOARD_LEN) ? -1 : minMoves;%0A  %7D%0A%7D%0A

Create the-quickest-way-up.java