Trains the technique from
LeetCode 779K-th Symbol in GrammarThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A loom builds a pattern one row at a time. Row 1 is a single symbol, 0. Every later row is woven from the row above it by replacing each of its symbols, left to right, with a pair: a 0 becomes 0 then 1, and a 1 becomes 1 then 0.
So row 2 reads 01, row 3 reads 0110, and in general row r holds 2^(r - 1) symbols.
Given a row number row and a position spot, counting positions from 1 at the left, return the symbol standing at that position of that row. The row can be far too wide to write out, so do not weave it symbol by symbol.
Example 1
Row 3 reads 0110, and its third symbol is 1.
Example 2
Row 4 reads 01101001, and its fifth symbol is 1.
Example 3
Row 5 holds 16 symbols and reads 0110100110010110, so the symbol at the far right is 0.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def woven_symbol(row: int, spot: int) -> int:public int wovenSymbol(int row, int spot)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.