All problems
0494EasyArrayHash TableSorting

Absent Marker Posts

Tracked in this browser only
Write code

Trains the technique from

LeetCode 3731Find Missing Elements

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 walks a trail and notes the number stamped on every marker post it comes across. found[i] is the number on the i-th post noted down. The crew doubles back a few times, so the notes are in no particular order and a post can appear in them more than once.

Take the smallest number in found and the largest number in found. Return, in increasing order, every whole number that lies strictly between those two and does not appear anywhere in found. Return an empty list when there is no such number.

Examples

Example 1

Input
found = [17, 12, 20, 12, 15]
Output
[13, 14, 16, 18, 19]

The notes run from 12 up to 20, and of the numbers in between only 15 and 17 were noted, so the rest are reported.

Example 2

Input
found = [63, 61, 62]
Output
[]

The span from 61 to 63 has just 62 inside it, and 62 was noted, so nothing is missing.

Example 3

Input
found = [88, 88]
Output
[]

The smallest and largest notes are the same number, so the span between them holds nothing at all.

Constraints

  • 2 <= found.length <= 100
  • 1 <= found[i] <= 100

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 absent_posts(found: list[int]) -> list[int]:
Java
public List<Integer> absentPosts(int[] found)
September 7
Apply