{"id":10351,"date":"2025-04-15T18:17:03","date_gmt":"2025-04-16T01:17:03","guid":{"rendered":"https:\/\/zxi.mytechroad.com\/blog\/?p=10351"},"modified":"2026-03-02T03:20:09","modified_gmt":"2026-03-02T11:20:09","slug":"leetcode-3512-minimum-operations-to-make-array-sum-divisible-by-k","status":"publish","type":"post","link":"https:\/\/zxi.mytechroad.com\/blog\/math\/leetcode-3512-minimum-operations-to-make-array-sum-divisible-by-k\/","title":{"rendered":"LeetCode 3512. Minimum Operations to Make Array Sum Divisible by K"},"content":{"rendered":"\n<p>\u6c42\u5408\u53d6\u4f59\u5373\u53ef\uff0c\u4f59\u6570\u5c31\u662f\u7b54\u6848\u3002<\/p>\n\n\n\n<p>Time complexity: O(n)<br>Space complexity: O(1)<\/p>\n\n\n\n<pre lang=\"c++\">\nclass Solution {\npublic:\n  int minOperations(vector<int>& nums, int k) {\n    return accumulate(begin(nums), end(nums), 0) % k;\n  }\n};\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6c42\u5408\u53d6\u4f59\u5373\u53ef\uff0c\u4f59\u6570\u5c31\u662f\u7b54\u6848\u3002 Time complexity: O(n)Space complexity: O(1) class Solution { public: int minOperations(vector&#038; nums, int k) { return accumulate(begin(nums), end(nums), 0) % k; } };<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[222,31,158,62],"class_list":["post-10351","post","type-post","status-publish","format-standard","hentry","category-math","tag-easy","tag-math","tag-mod","tag-sum","entry","simple"],"_links":{"self":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/10351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/comments?post=10351"}],"version-history":[{"count":3,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/10351\/revisions"}],"predecessor-version":[{"id":10615,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/10351\/revisions\/10615"}],"wp:attachment":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/media?parent=10351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/categories?post=10351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/tags?post=10351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}