How to use a 'two pointer' algorithm in Elixir

The best approach would be to come up with an algorithm that works well with immutable data structures. But the reality is that it’s going to be extra work since most of the problems of this kind are designed with the assumption that an array with O(1) random access time is the most basic data structure available in any given language. This is just not true for Elixir since it mostly works with tuples (fixed size, O(1) access) or lists (O(1) prepend and O(N) random access).

Using a map got me through all of Advent of Code exercises, so I think it’s a viable solution. But I would be extra careful trying to push that approach for production-ready systems.