Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ee61486

Browse files
committed
Add kids with candies
1 parent 0a2cf49 commit ee61486

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

‎array_string/kids_with_the_greatest_number_of_candies/__init__.py

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def kidsWithCandies(self, candies: List[int], extraCandies: int) -> List[bool]:
6+
max_candies = max(candies)
7+
return [current_candies + extraCandies >= max_candies for current_candies in candies]

‎tests/test_kids_with_candies.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
from array_string.kids_with_the_greatest_number_of_candies.solution import Solution
3+
4+
@pytest.mark.parametrize("candies, extraCandies, expected", [
5+
([2, 3, 5, 1, 3], 3, [True, True, True, False, True] ),
6+
([4, 2, 1, 1, 2], 1, [True, False, False, False, False]),
7+
([12, 1, 12], 10, [True, False, True])
8+
])
9+
def test_merge_alternately(candies, extraCandies, expected):
10+
solution = Solution()
11+
assert solution.kidsWithCandies(candies, extraCandies) == expected

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /