This documentation is automatically generated by online-judge-tools/verification-helper

:warning: src/collection/mex.cr

Required by

Code

module Enumerable(T)
  # Returns the minimum value of the complement set.
  def mex_sorted : T
    reduce(T.zero) do |now, x|
      next now if x < T.zero
      return now if now < x
      x.succ
    end
  end

  # :ditto:
  def mex : T
    to_a.sort!.mex_sorted
  end
end
module Enumerable(T)
  # Returns the minimum value of the complement set.
  def mex_sorted : T
    reduce(T.zero) do |now, x|
      next now if x < T.zero
      return now if now < x
      x.succ
    end
  end

  # :ditto:
  def mex : T
    to_a.sort!.mex_sorted
  end
end
Back to top page