Company: Commmenwealth bank of Australia IITR
Difficulty: medium
Calculate Time to Reach Block Problem Description Sangeeta jogs across a square park of N by N blocks. She always starts at the top left block and always runs the same zig-zag route, spending one minute on each block. The number written in a block is the minute at which she arrives there, so the top left block is 1 . Her route sweeps the park one anti-diagonal at a time. An anti-diagonal is the set of blocks whose row and column add up to the same value, and she finishes one anti-diagonal completely before starting the next. She walks the anti-diagonals alternately upwards and downwards, which is what makes the route zig-zag. For a 4 x 4 park the arrival minutes are 1 3 4 10 2 5 9 11 6 8 12 15 7 13 14 16 Blocks are 0-indexed: the top left block is (0, 0) and the bottom right block is (N - 1, N - 1) . The first coordinate is the row and the second is the column. Given N and a block (x, y) , print the minute at which Sangeeta arrives there. Function Description Complete the calculateTime