TCS NQT Full Mock 2: Advanced Coding
Part 2 of TCS NQT Full Mock 2: two problems in 90 minutes, like the Advanced Coding section that Digital and Prime need. Practice problems written for this site in the style of the real test.
2 problems, 90 minutes, marks 50 / 50.
Problem 1: Fewest railway platforms (Medium, 50 marks)
N trains stop at a station on the same day; each has an arrival and a departure time (HH:MM). A train uses a platform from its arrival minute to its departure minute, both included, so a train arriving at the minute another leaves needs a different platform. Find the fewest platforms needed.
Input: First line: N. Next N lines: arrival and departure times.
Output: The fewest platforms.
Constraints: 1 ≤ N ≤ 10^5; times are from 00:00 to 23:59 and departure is not before arrival.
Input:
3
09:00 09:10
09:05 09:20
09:15 09:30
Output:
2Problem 2: Paths through a blocked grid (Hard, 50 marks)
An R × C grid has free cells (.) and blocked cells (#). Starting at the top-left cell, you move one step right, one step down or one step diagonally down-right, only onto free cells. Count the paths to the bottom-right cell, modulo 10^9 + 7 (0 if the start or end is blocked).
Input: First line: R and C. Next R lines: the grid rows.
Output: The number of paths modulo 10^9 + 7.
Constraints: 1 ≤ R, C ≤ 1000.
Input:
2 2
..
..
Output:
3