Skip to content

Instantly share code, notes, and snippets.

@seanchen1991
Last active February 28, 2019 18:19
Show Gist options
  • Save seanchen1991/83d199b8b32b748912bfa4ffa853deac to your computer and use it in GitHub Desktop.
Save seanchen1991/83d199b8b32b748912bfa4ffa853deac to your computer and use it in GitHub Desktop.
Smallest Missing Element from a Sorted Array

Find the Smallest Missing Element from a Sorted Array

Given a sorted array of distinct non-negative integers, find the smallest missing element in it.

Examples

Input: A = [0, 1, 2, 6, 9, 11, 15] Output: The smallest missing element is 3

Input: A = [1, 2, 3, 4, 6, 9, 11, 15] Output: The smallest missing element is 0

Input: A = [0, 1, 2, 3, 4, 5, 6] Output: The smallest missing element is 7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment