Node class
class Node
**Initialize with input - value**
value -> value
prev -> null
next -> null
| """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 |
| 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) |
| """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 |
| """With At Most Two Distinct Characters""" | |
| from collections import Counter | |
| def longest_substring_count_at_most_two(s): | |
| counter = Counter() | |
| fast, max_length = 0, 0 | |
| for lag, char in enumerate(s): | |
| counter[char] += 1 | |
| while len(counter) > 2: |
Just migrated it from Codepen.io to markdown. Credit goes to David Conner.
| Working with DOM | Working with JS | Working With Functions |
|---|---|---|
| Accessing Dom Elements | Add/Remove Array Item | Add Default Arguments to Function |
| Grab Children/Parent Node(s) | Add/Remove Object Properties | Throttle/Debounce Functions |
| Create DOM Elements | Conditionals |
| /*HASH TABLE - a dictionary/hash map data structure for storing key/value pairs. Finding | |
| an entry in a hash table takes O(1) constant time(same for 10 as 1 billion items). Whereas | |
| finding an item via binary search takes time proportional to the logarithm of | |
| the item in the list O(logn). Finding an item in a regular old list takes time proportional to | |
| the length of the list O(n). Very slow. Hash Tables = very fast */ | |
| var makeHashTable = function(max) { | |
| var storage = [], | |
| hashTableMethods = { |