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

:heavy_check_mark: src/collection/compress.cr

Required by

Verified with

Code

class Array(T)
  def compress(values : Array(T), *, index : Int = 0)
    map do |x|
      index + values.bsearch_index { |y| y >= x }.not_nil!
    end
  end

  def compress(*, index : Int = 0) : Array(Int32)
    compress(uniq.sort!, index: index)
  end
end
class Array(T)
  def compress(values : Array(T), *, index : Int = 0)
    map do |x|
      index + values.bsearch_index { |y| y >= x }.not_nil!
    end
  end

  def compress(*, index : Int = 0) : Array(Int32)
    compress(uniq.sort!, index: index)
  end
end
Back to top page