Could you check if there's an approach that isn't `O(n^2)`? Current is used in loops...