[Rust / Elixir] patience sort
Approach\nUse patience sort to find the longest non-decreasing subsequence for each:\narr.iter().skip(i).step_by(k) or\nEnum.drop(i) |> Enum.take_every(k),\nwhe
# Approach\nUse patience sort to find the longest non-decreasing subsequence for each:\n`arr.iter().skip(i).step_by(k)` or\n`Enum.drop(i) |> Enum.take_every(k)`,\nwhere `0 <= i < k`.\n\n# Complexity\n- Time complexity: $$O(n*log(n / k))$$\n\n- Space complexity: $$O(n)$$\n\n# Code\n```Rust []\nimpl Solution {\n    pub fn k_increasing(arr: Vec<i32>, k: i32) -> i32 {\n        let k = k as usize;\n        let mut ans = 0;\n        let mut patience = Vec::<i32>::new();\n        for i in 0..k {\n            patience.clear();\n            for j in (i..arr.len()).step_by(k) {\n                let p = patience.partition_point(|&x| x <= arr[j]);\n                if p == patience.len() {\n                    patience.push(arr[j]);\n                }\n                else {\n                    patience[p] = arr[j];\n                    ans += 1;\n                }\n            }\n        }\n        ans\n    }\n}\n```\n```Elixir []\ndefmodule Solution do\n  @spec k_increasing(arr :: [integer], k :: integer) :: integer\n  def k_increasing(arr, k) do\n    Enum.chunk_every(arr, k, k, Stream.cycle([nil]))\n    |> Enum.zip_with(fn list ->\n      Enum.with_index(list)\n      |> Enum.reduce({0, :gb_sets.new()}, fn tuple, {ans, sets} ->\n        {ans, sets} =\n          case :gb_sets.iterator_from(tuple, sets) |> :gb_sets.next() do\n            {ele, _} -> {ans + 1, :gb_sets.delete(ele, sets)}\n            :none -> {ans, sets}\n          end\n        {ans, :gb_sets.add(tuple, sets)}\n      end)\n      |> elem(0)\n    end)\n    |> Enum.sum()\n  end\nend\n```
['Binary Search', 'Rust', 'Elixir']