# 2600. K Items With the Maximum Sum ###### tags: `Leetcode` `Easy` Link: https://leetcode.com/problems/k-items-with-the-maximum-sum/description/ ## Code ```python= class Solution: def kItemsWithMaximumSum(self, numOnes: int, numZeros: int, numNegOnes: int, k: int) -> int: if k<=numOnes or k<=numOnes+numZeros: return min(numOnes, k) else: return numOnes+(-1)*(k-numOnes-numZeros) ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up