mediumIntroduction to ArraysPattern: Mixed
Rectangular Block Rotation Solution
Problem Statement
Given a two-dimensional array of integers representing rectangular blocks, where each block is defined by its height and width, rotate all blocks by 90 degrees clockwise and return the resulting array of blocks.
Examples
Example 1:
Input:[[12],[34]]
Output:[[34],[12]]
Explanation: Rotating the blocks by 90 degrees clockwise results in swapping the rows and reversing the columns.
Example 2:
Input:[[5],[6]]
Output:[[6],[5]]
Explanation: Rotating a single column block by 90 degrees clockwise does not change its height but reverses its order.
Constraints
- {"type":"integer","min":1,"max":100,"description":"Number of blocks"}
- {"type":"integer","min":1,"max":100,"description":"Maximum height and width of each block"}
Time: O(n) Space: O(h*w)
Analyze constraints and compute optimal solutions step-by-step.
Run, Test & Submit Code
Ready to practice this challenge? Launch our interactive compilation environment with compiler validation.
Solve on Interactive WorkspaceTested Solutions
No solution code is currently loaded.
Complete this code in the workspace editor.
