Trains the technique from
LeetCode 504Base 7This 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 museum shows an old counting frame that works in sevens. Each rod carries from zero to six beads, and a rod is worth seven times the rod immediately to its right, so the rightmost rod counts ones, the next counts sevens, the next counts forty-nines, and so on.
Given an integer value, return the text a curator would write on the label: the bead count of each rod, read from the leftmost rod that carries a bead down to the ones rod, with no extra zero in front. If value is negative, put a single - before those digits. If value is zero, the label is the single character 0.
Example 1
Six beads on the forty-nines rod, six on the sevens rod and six on the ones rod come to 294 plus 42 plus 6.
Example 2
Forty-eight is six sevens plus six ones, and the value is negative, so the label carries a leading minus.
Example 3
2401 is seven multiplied by itself four times, so a single bead sits on the fifth rod from the right and every rod to its right is bare.
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 to_base_seven(value: int) -> str:public String toBaseSeven(int value)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.