- Looks like it works and is O(N)
- You could return early if you found a difference of 0
- You could store the current difference, rather than the current left part, if you wanted to.
How to measure the "correctness"? Well, just do your level best to "prove" the method outside of code and then subject it to lots of tests. (Dreaming up a comprehensive set of tests, that include all "edge" cases, is quite hard in itself. I've left the basic assumption that A has 2 elements at least here.)
I don't "measure" the time complexity - I just inspect the algorithm. Usually, I refer to a few known cases: straight traversal O(N); nested loops O(N^2); sorting O(N log N) usually; setting up a tree, set or map O(N log N).
I prefer a minimum set of data types (I have a long background in Fortran!). So, I simply put up with the warning about signed and unsigned types when I know my indices aren't negative. Many languages don't have unsigned types and I don't particularly like them. You can't subtract them both ways, for example. Sure, arrays (in c++) only have positive or zero indices, but that isn't universally true in other languages.