Loading...
Loading...
Loading...
The class representative drafts timetable changes by swapping periods on a copy. The real timetable must not change until the draft is approved. Copy the 2D grid deeply, apply the swaps to the draft only, and print both.
Real:, then d lines of the real timetable; Draft:, then d lines of the draft. Codes separated by single spaces.Example
Input
2 3 Java DBMS Maths OS Java Lab 1 1 1 3
Output
Real: Java DBMS Maths OS Java Lab Draft: Maths DBMS Java OS Java Lab
Day 1, periods 1 and 3 swap in the draft only.
Try the problem first. Open one hint at a time.
grid.clone() copies only the row references: swaps would reach the real timetable.
Make a new String[d][] and clone each row into it.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor