Git Product home page Git Product logo

cp-question's Introduction

CP-Question

I am stuck at this Question, i have coded something but its not time efficient, any sort of help is appreciable.

Markov takes out his Snakes and Ladders game, stares at the board and wonders: "If I can always roll the die to whatever number I want, what would be the least number of rolls to reach the destination?"

Rules The game is played with a cubic die of 6 faces numbered 1 to 6.

  1. Starting from square 1, land on square 100 with the exact roll of the die. If moving the number rolled would place the player beyond square 100 , no move is made.

  2. If a player lands at the base of a ladder, the player must climb the ladder. Ladders go up only.

  3. If a player lands at the mouth of a snake, the player must go down the snake and come out through the tail. Snakes go down only.

Function Description :

Complete the quickestWayUp function in the editor below. It should return an integer that represents the minimum number of moves required.

quickestWayUp has the following parameter(s):

ladders: a 2D integer array where each ladders[i] contains the start and end cell numbers of a ladder snakes: a 2D integer array where each snakes[i] contains the start and end cell numbers of a snake

Input Format

The first line contains the number of tests, .

For each testcase:

  • The first line contains , the number of ladders.
  • Each of the next lines contains two space-separated integers, the start and end of a ladder.
  • The next line contains the integer , the number of snakes.
  • Each of the next lines contains two space-separated integers, the start and end of a snake.

Sample Input

2 3 32 62 42 68 12 98 7 95 13 97 25 93 37 79 27 75 19 49 47 67 17 4 8 52 6 80 26 42 2 72 9 51 19 39 11 37 29 81 3 59 5 79 23 53 7 43 33 77 21

Sample Output

3 5

Just add your file in respective lang or edit my solution.

Thankyou.

cp-question's People

Contributors

divyanshsikarwar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.