Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 481. Magical String
Generate the infinite self-referential binary sequence s (starting "122112...") whose run lengths equal the sequence itself, and return how many '1's appear in the first n characters. The core challenge is to simulate this run-length–defined sequence efficiently (linear in n) to count the ones.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.