Contains Duplicate
Real-world version: Repeated Elevation MarkerThe statement here is our own: the same inputs, outputs and technique.
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 starts with this. It matches the parent problem's shape, so a solution that works here works on a standard judge unchanged.
def repeated_elevation(marks: list[int]) -> bool:public boolean repeatedElevation(int[] marks)Checking your plan…
How this problem was checked
- Passed: Reference solution run against 9 test cases: 9 passed
- Passed: 3 worked examples confirmed by running the code
- Passed: 0 eight-word sequences shared with the parent problem's text
- Passed: Agrees with an independent brute-force solution on random inputs
- Passed: Test set shown to catch deliberately broken solutions
- Passed: Reviewed by a separate quality pass
- Passed: Function arity matches the parent problem's