Last active
December 6, 2021 08:05
-
-
Save ylt6/96ea54e6a0f26596d3bcaeecbab6456f to your computer and use it in GitHub Desktop.
Scoreboard Inference (Chapter 1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.facebookrecruiting.com/portal/coding_puzzles/?puzzle=348371419980095 | |
from typing import List | |
# Write any import statements here | |
def getMinProblemCount(N: int, S: List[int]) -> int: | |
# Write your code here | |
is_even = lambda x: True if x % 2 == 0 else False | |
max_v = float('-inf') | |
has_odd = False | |
for n in S: | |
if n > max_v: | |
max_v = n | |
if not has_odd and not is_even(n): | |
has_odd = True | |
return max_v // 2 + 1 if has_odd else max_v // 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment