All problems
0450EasyArrayHash Table

Distinct Tallies In A Core Log

Tracked in this browser only
Write code

Trains the technique from

LeetCode 1207Unique Number of Occurrences

This 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.

Examples

Example 1

Input
offsets = [-40, 7, -40, 7, 65]
Output
false

Offset -40 was sampled twice, offset 7 was sampled twice as well, so two different offsets share a tally.

Example 2

Input
offsets = [-5, -5, -5, 62, 91, 62, 14]
Output
false

The tallies are three samples at -5, two at 62 and one each at 91 and 14, and the two singles clash.

Example 3

Input
offsets = [-1000, -1000, -1000, -1000]
Output
true

Only one offset appears in the log, so there is no second tally for it to clash with.

Constraints

  • 1 <= offsets.length <= 1000
  • -1000 <= offsets[i] <= 1000

The signature

The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

Python
def all_tallies_differ(offsets: list[int]) -> bool:
Java
public boolean allTalliesDiffer(int[] offsets)
September 7
Apply