Posts

Showing posts from March 9, 2021

Rearrange Integer Matrix - Alphabets

 Rearrange Integer Matrix - Alphabets  PROBLEM STATEMENT : The program must accept an integer matrix M1 and a character matrix M2 having the same size R*C as the input. The matrix M2 contains only lower case alphabets. The program must rearrange the integer matrix M1 based on the positions of the alphabets in M2 after sorting the alphabets. The integer value in M1 must be relocated to the original position (before sorting) of the alphabet in M2 in having the same position in the sorted matrix M2. If two or more alphabets are same, then the program must consider them in the order of their occurrence. Finally, the program must print the modified matrix M1 as the output.  Boundary Condition(s):  2 <= R, C <= 50  1 <= Matrix element value <= 1000  Input Format:  The first line contains R and C separated by a space.  The next R lines, each contains C integer values representing the integer matrix M1.  The next R lines from the (R+2)th ...

Zig-Zag Robots

 Zig-Zag Robots  PROBLEM STATEMENT : There are R robots in R rows (i.e., one robot in each row). There are two types of robots which are given below.  Type 1: The robots start moving towards the East. Once it reaches the end of the row, it again starts moving towards the West. Similarly, the type 1 robots move in the direction East-West alternatively.  Type 2: The robots start moving towards the West. Once it reaches the end of the row, it again starts moving towards the East. Similarly, the type 2 robots move in the direction West-East alternatively. The speed of each robot is 1 meter per second. The length of each row is C meters. The initial state of the robots is passed as the input. The program must print the state of the robots after T seconds as the output. The value of T is also passed as the input.  Boundary Condition(s):   2 <= R, C <= 50  1 <= T <= 10^4  Input Format:   The first line contains R and C separated by a s...