Skip to content

Instantly share code, notes, and snippets.

@ylt6
Last active December 6, 2021 08:05
Show Gist options
  • Save ylt6/96ea54e6a0f26596d3bcaeecbab6456f to your computer and use it in GitHub Desktop.
Save ylt6/96ea54e6a0f26596d3bcaeecbab6456f to your computer and use it in GitHub Desktop.
Scoreboard Inference (Chapter 1)
# 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