Trains the technique from
LeetCode 1207Unique Number of OccurrencesThis 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 drilling crew tags every core sample it lifts with the signed offset of the level it came from, in decimetres above the survey datum. Levels below the datum carry a negative offset, and offsets lists one tag per sample in the order the samples were lifted.
The crew calls a log well spread when no two different offsets were sampled the same number of times. An offset that appears once and another that also appears once spoils that, while an offset sampled once alongside one sampled four times does not.
Return true if the log is well spread and false otherwise. Note that -40 and 40 are different offsets.
Example 1
Offset -40 was sampled twice, offset 7 was sampled twice as well, so two different offsets share a tally.
Example 2
The tallies are three samples at -5, two at 62 and one each at 91 and 14, and the two singles clash.
Example 3
Only one offset appears in the log, so there is no second tally for it to clash with.
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 all_tallies_differ(offsets: list[int]) -> bool:public boolean allTalliesDiffer(int[] offsets)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.