I recommend just `return L, D`, which is idiomatic. Forming a list is more confusing. The final returned `D` should just be `(n,)`-shaped instead of `(n, 1)`. I expect it can just be `(n,)`-shaped through the whole algorithm. The example needs to be updated to match your code.