← All problemsSign in

Rain vs City

You are given an n*m matrix A. A[1][1] is the top-left cell, and A[n][m] is the bottom-right cell. You want to fill a matrix B[n][m] using the following pseudo code. All the entries of matrix B are zero initially. randomInt(a, b) returns an uniform random integer between a and b (both inclusive). That is, all the b-a+1 integers have an equal probability of being returned. For x = 1 to n:

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start