🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Matrix Traversal: all 13 questions

Quiz: Matrix Traversal · Question 7 of 13

What is the time complexity of printing an R × C matrix in spiral order?

What is the time complexity of printing an R × C matrix in spiral order?

  1. A.O(R + C)
  2. B.O(R × C)
  3. C.O(R × C × log(R × C))
  4. D.O((R × C)²)
Answer & explanation

Correct answer: O(R × C)

Every cell is visited exactly once.

Can you get the rest right without peeking?

Take the timed Quiz: Matrix Traversal quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →