↓Skip to main content
  1. LeetCode/

LeetCode 3512: Minimum Operations to Make Array Sum Divisible by K

·1 min· ·
LeetCode Biweekly-Contest Easy
Wei Yi Chung
Author
Wei Yi Chung
Working at the contributing of open source, distributed systems, and data engineering.
Table of Contents
LeetCode Bi-Weekly Contest 154 - This article is part of a series.
Part 1: This Article

Meta Data
#

Difficulty: easy First Attempt: 2025-04-12

  • Total time: 01:00.00

Intuition
#

The problem need to count the minimum operations to make the array sum can de divided by K, thus we just need to find how many count we should do, means to get the reminder of nums and k

Approach
#

class Solution:
    def minOperations(self, nums: List[int], k: int) -> int:
        return sum(nums)%k

Findings
#

NA

Encountered Problems
#

NA

LeetCode Bi-Weekly Contest 154 - This article is part of a series.
Part 1: This Article

Related

LeetCode 3513: Number of Unique XOR Triplets I
·2 mins
LeetCode Biweekly-Contest Medium Bit-Manipulation Unsolved
LeetCode Problem Solving
LeetCode 2843: Count Symmetric Integers
·1 min
LeetCode Daily Easy Digit-Dp
LeetCode Problem Solving
LeetCode 617: Merge Two Binary Trees
·2 mins
LeetCode Daily Easy Tree
LeetCode Problem Solving
LeetCode 3507: Minimum Pair Removal to Sort Array I
·2 mins
LeetCode Easy Simulation Array
LeetCode 3507 note: n is tiny, so simulate; the right side of a slice assignment must be a list
LeetCode 3492: Maximum Containers on a Ship
·1 min
LeetCode Easy Math
LeetCode 3492 note: at most n² cells and at most maxWeight // w by weight, so take the smaller, using integer division
LeetCode 1431: Kids With the Greatest Number of Candies
·1 min
LeetCode Easy Array
LeetCode 1431 note: compute the maximum once; a kid is True when their candies plus the extra reach >= the maximum, since a tie counts