Skip to content

Commit

Permalink
added stringdoc for mex algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanExtreme002 committed May 10, 2024
1 parent 2eb1ce1 commit 43e74e9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fastsnake/algorithms/mex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
def mex(array):
"""
The MEX (minimum excluded) of an array is the smallest non-negative integer that
does not belong to the array. Example:
The MEX of [2,2,1] is 0, because 0 does not belong to the array.
The MEX of [3,1,0,1] is 2, because 0 and 1 belong to the array, but 2 does not.
The MEX of [0,3,1,2] is 4 because 0, 1, 2 and 3 belong to the array, but 4 does not.
"""
# Create a dictionary to store the frequency of each element
freq_map = {}

Expand Down

0 comments on commit 43e74e9

Please sign in to comment.