Question: Flipkart Grid | Recently Asked Online Assessments (OA) in 31 Jul, 2025 | Geeta's River Crossing | LHC Pod Navigation |Complete Solutions & Tips | Array Jumps & BFS Shortest Path
0
Entering edit mode

Question 1: Geeta's River Crossing (Log Jumps)

Problem Statement:

Geeta wants to cross a river which does not have a bridge across it. She found some logs floating on the water and decides to cross the river by jumping from one log to the next. She noticed something peculiar about these logs - they were all very slippery and someone had tied them together at the left end to hold them parallel to each other. Only the right end of the logs was good enough to get some grip. So she decided to cross the river by jumping from the right end of one log to the next. However all the logs were of different lengths, which meant in each jump she had to also go a certain distance left or right.

Geeta knew she could only jump a fixed distance to her right and to her left. So if the logs were more apart than that, she would have to turn back and reach her starting position. Her first priority was to reach the opposite bank, but if left with no choice she would return back to her starting position.

Write a program to print the number of jumps Geeta makes before reaching either the opposite end or her starting position.

Read the input from STDIN and print the output to STDOUT. Do not write arbitrary strings anywhere in the program, as these contribute to the standard output and testcases will fail.

Constraints:

I) N≥1, the number of logs

II X,Y≥0; maximum distance Geeta can jump left and right respectively

III) Length of any log ≥1

Input Format:

The first line of input contains N, X and Y separated by a single white space.

Question 2: Large Hadron Collider (LHC) Pod Navigation

Problem Statement:

The Large Hadron Collider (LHC) is the world's largest particle accelerator. It lies underground in a circular tunnel 27 kilometers in circumference. All of its components spread throughout the circumference, need to function optimally for the Collider to do its job. To quickly reach a component that needs repairs, a pod on rails has been built, which runs in the tunnel in a loop.

There are N stations (numbered 1 to N) in the tunnel where the pod can stop. Inside the pod, a number pad with digits 0 to 9, and an 'Enter' button are given. One can enter the number of the station one wants to go to, press Enter, and the pod will go to that station. There are also two additional buttons: button F to move just one station forward (e.g. from station 34 to station 35), and button B to move one station backward (e.g. from station 38 to station 37). One need not press 'Enter' after pressing F or B.

One morning, it was discovered that some digits on the number pad had stopped functioning, although buttons E (Enter), F, and B were working fine. Since the repair work cannot control, engineers are trying to figure out the fastest way to reach any station using only the functioning buttons.

Write a program to help the engineers find the fewest button presses required to reach their destination station from their starting station. Print the number of button presses as the output.

Read the input from STDIN and print the output to STDOUT. Do not write arbitrary strings anywhere in the program, as these contribute to the standard output and testcases will fail.

Constraints:

N<10000

 

ADD COMMENTlink 9 days ago Rohit • 40

Login before adding your answer.

Similar Posts
Loading Similar Posts