Skip to content

Instantly share code, notes, and snippets.

@aashish-chaubey
Created July 11, 2021 14:36
Show Gist options
  • Select an option

  • Save aashish-chaubey/51aa70a61932739e03311e239e3eaf1b to your computer and use it in GitHub Desktop.

Select an option

Save aashish-chaubey/51aa70a61932739e03311e239e3eaf1b to your computer and use it in GitHub Desktop.

Revisions

  1. aashish-chaubey created this gist Jul 11, 2021.
    15 changes: 15 additions & 0 deletions task_of_pairing.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    def taskOfPairing(freq):
    count = 0
    marker = False
    for i in freq:
    if i != 0:
    count += i // 2
    if i % 2 != 0 and marker:
    count += 1
    marker = False
    elif i % 2 != 0:
    marker = True
    else:
    marker = False
    return count