Skip to content

Instantly share code, notes, and snippets.

"""Max Consecutive Ones II"""
def max_consecutive_ones_II(bits):
res = max_count = 0
counter = Counter()
for i in range(len(bits)):
counter[bits[i]] += 1
maxf = max(maxf, counter[bits[i]])
if res - maxf < 1:
res += 1
@DixieKorley
DixieKorley / three_sum_smallest.py
Last active June 20, 2019 22:31
Three sum smallest problem
"""Three Sum Smallest"""
def three_sum_smaller(nums, target):
n = len(nums)
if nums is None or n < 3:
return 0
result = 0
for left in range(n - 2):
middle = left + 1
right = n - 1
@DixieKorley
DixieKorley / character_input.py
Last active June 24, 2019 17:42
Exercises from Practice Python
from datetime import datetime
"""Character Input Exercise"""
name = input("Hi there. What is your name? ")
age = input("Hey, " + name + ", how old are you? ")
year = datetime.today().year
year_at_hundred = year + (100 - int(age))
end_message = "Nice! Sounds like you will be a 100 in " + str(year_at_hundred) + "!"
print(end_message)
@DixieKorley
DixieKorley / doubly_linked_list.md
Last active June 1, 2023 17:43
pseudocode for doubly linked list

Pseudocode

Node class

class Node
  **Initialize with input - value**
     value -> value
     prev -> null
     next -> null