Skip to content
U
uByte
Tutorials
🐹
Go
Beginner-friendly
🐍
Python
Clean & readable
🟨
JavaScript
Web & Node.js
☕
Java
Enterprise & OOP
🦀
Rust
Systems programming
⚙️
C++
Performance & control
💜
C#
.NET & game dev
Interview Prep
🎯
All problems
Browse every language
🐹
Go
🐍
Python
🟨
JavaScript
☕
Java
🦀
Rust
⚙️
C++
💜
C#
⚡
Daily challenge
One problem, every day
🎤
Interview simulator
Timed mock interview session
💬
Interview experiences
Real stories shared anonymously
Certifications
📝
Certifications
Coding exams by language
🐹
Go
🐍
Python
🟨
JavaScript
☕
Java
🦀
Rust
⚙️
C++
💜
C#
U
uByte
// Spiral Matrix II — MEDIUM
// Category: array
Given a positive integer `n`, generate an `n x n` matrix filled with elements from 1 to n² in spiral order.
Example: n = 3
Output: [[1,2,3],[8,9,4],[7,6,5]]
Spiral Matrix II — Pro only
Sign up free to start solving problems. The daily challenge is always free — no account needed.
BEST VALUE
Yearly Pro
$49.99/year
Save $69.89 vs monthly
Monthly Pro
$9.99/month
Cancel anytime
Create free account →
Already have an account? Sign in
← Back to C++ problems