Day 3 of our DSA Mastery Series! Stay ahead in your tech career with HeyCoach's expert insights.

Page 1

ROADMA
Swipe for more >
30 DAYS DSA
P

DAY 3

Rotate Image

Diťťiculty –

M edium

You aie given an n x n 2D matiix iepiesenting an image, iotate the image by 90 degiees (clockwise).

You have to iotate the image in-place, which means you have to modify the input 2D matiix diiectly.

Example:

Input: nums = [[1,2,3],[4,5,6], [7,8,9]]

Output: [[7,4,1],[8,5,2],[9,6,3]]

Matíices
Píoblem link

Spiíal Matíix

Diťťiculty –M edium

Given an m x n matíix, íetuín all elements of the matíix in spiíal oídeí.

Example:

Input: nums = [[1,2,3],[4,5,6], [7,8,9]]

Output: [1,2,3,6,9,8,7,4,5]

Píoblem link

Spiíal Matíix II

DiťťicultyM edium

Given a positive integeí n, geneíate an n x n matíix filled with elements fíom 1 to n^ 2 in spiíal oídeí.

Example:

Input: n = 3

Output: [[1,2,3],[8,9,4], [7,6,5]]

Píoblem link

Set Matíix Zeíoes

DiťťicultyM edium

Given an m x n integeí matíix matíix, if an element is 0, set its entiíe íow and column to 0's. You must do it in place.

Example:

Input: nums = [[1,1,1],[1,0,1], [1,1,1]]

Output: [[1,0,1],[0,0,0],[1,0,1]]

Píoblem link

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.