LeetCode 3870 Elixir solution

May be it's solution for fun. One row of code.

These problems once again highlight a simple truth: we need to think first and only then implement the solution.

You can see the solutions of this problem on C++, Java, JavaScript, TypeScript, Python with a solution explanation here


Time complexity: O(1)
Space complexity: O(1)


Elixir

defmodule Solution do
  @spec count_commas(n :: integer) :: integer
  def count_commas(n) do
    max(0, n - 999)
  end
end