Yes it works but there’s a much more efficient solution in O(n^2).
The linear algebra solution is fine but it requires already O(n^4) for computing the matrix alone.
              
              
              4 Likes
            
          Yes it works but there’s a much more efficient solution in O(n^2).
The linear algebra solution is fine but it requires already O(n^4) for computing the matrix alone.