← 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?
- A.O(R + C)
- B.O(R × C)
- C.O(R × C × log(R × C))
- 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 →