Skip to content

Instantly share code, notes, and snippets.

@ylt6
Last active December 6, 2021 08:05
Show Gist options
  • Select an option

  • Save ylt6/96ea54e6a0f26596d3bcaeecbab6456f to your computer and use it in GitHub Desktop.

Select an option

Save ylt6/96ea54e6a0f26596d3bcaeecbab6456f to your computer and use it in GitHub Desktop.

Revisions

  1. ylt6 renamed this gist Dec 6, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. ylt6 revised this gist Dec 6, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion _.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    // https://www.facebookrecruiting.com/portal/coding_puzzles/?puzzle=348371419980095
    # https://www.facebookrecruiting.com/portal/coding_puzzles/?puzzle=348371419980095

    from typing import List
    # Write any import statements here
  3. ylt6 created this gist Dec 6, 2021.
    20 changes: 20 additions & 0 deletions _.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    // 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