Every so often it's good to exercise your brain with a math problem or two that forces you to recall principles you learned decades prior. As elementary as it might feel, you'd be surprised how easy ...
One simple rule can help solve any complex equation. Here's a hint: all it takes is a catchy acronym.
long[] leftMins = new long[n]; // sum of k smallest from left long[] rightMaxs = new long[n]; // sum of k largest from right long leftSum = 0, rightSum = 0, minDiff = Long.MAX_VALUE; ...