<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>OAs on Algorithm Solutions</title><link>https://algorithm.liangqin.ren/oa/</link><description>Recent content in OAs on Algorithm Solutions</description><generator>Hugo -- gohugo.io</generator><lastBuildDate>Thu, 17 Sep 2026 21:13:59 -0500</lastBuildDate><atom:link href="https://algorithm.liangqin.ren/oa/index.xml" rel="self" type="application/rss+xml"/><item><title>1. 至多删除一个元素后的最小分割差值</title><link>https://algorithm.liangqin.ren/oa/1/</link><pubDate>Thu, 17 Sep 2026 21:13:59 -0500</pubDate><guid>https://algorithm.liangqin.ren/oa/1/</guid><description>1. Description 给定一个包含 n 个正整数的数组 nums。
可以删除数组中的至多一个元素，也可以不删除任何元素。删除后，其余元素的相对顺序保持不变。
随后，将剩余数组分割成两个非空连续部分。设左半部分元素之和为 leftSum，右半部分元素之和为 rightSum。
请返回所有合法操作中最小的 leftSum 与 rightSum 的差值。
2. Solution Time complexity: O(nlogn)
Space complexity: O(n)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 int main() { int T; cin &amp;gt;&amp;gt; T; while (T-- &amp;gt; 0) { int n; cin &amp;gt;&amp;gt; n; vector&amp;lt;int64_t&amp;gt; weights(n); multiset&amp;lt;int64_t&amp;gt; left_weights, right_weights; for (int i = 0; i &amp;lt; n; ++i) { cin &amp;gt;&amp;gt; weights[i]; right_weights.</description></item></channel></rss>