All problems
0123EasyArrayHash TableSorting

Repeated Elevation Marker

Tracked in this browser only
Write code

Trains the technique from

LeetCode 217Contains Duplicate

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 survey crew stamps every benchmark it visits with that benchmark's height above the datum, in whole centimetres. Benchmarks sunk below the datum get a negative stamp, and one right on it gets 0. The stamps come back as the array marks, in visiting order.

A stamp is supposed to identify a benchmark on its own, so the crew needs to know whether any height was stamped on more than one benchmark. Return true if some value occurs at two or more positions of marks, and false if every stamp is distinct.

Heights the same distance either side of the datum are different heights: -40 and 40 are two separate stamps, not a repeat.

Examples

Example 1

Input
marks = [14, -3, 9, -3]
Output
true

The stamp -3 was used at the second benchmark and again at the last one, so the crew has a collision.

Example 2

Input
marks = [8, -20, 0, 5]
Output
false

Four different heights, one of them exactly at the datum, and no value comes back twice.

Example 3

Input
marks = [-6, 6]
Output
false

The two benchmarks sit the same distance from the datum but on opposite sides, so their stamps differ.

Constraints

  • 1 <= marks.length <= 10^5
  • -10^9 <= marks[i] <= 10^9

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 repeated_elevation(marks: list[int]) -> bool:
Java
public boolean repeatedElevation(int[] marks)
September 7
Apply