This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import markdownit from 'markdown-it'; | |
import React, { useState } from 'react'; | |
import { default as MdEditor } from 'react-markdown-editor-lite'; | |
import 'react-markdown-editor-lite/lib/index.css'; | |
type Props = { | |
initialText: string, | |
onChange?: (html: string, text: string) => void, | |
viewOnly: boolean, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter, defaultdict | |
class Solution: | |
def checkInclusion(self, s1: str, s2: str) -> bool: | |
original_letters = Counter(s1) | |
letters = defaultdict(int) | |
temp = deque() | |
for current_letter in s2: | |
temp.append(current_letter) | |
letters[current_letter] += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Dict | |
import os | |
def read_properties(file_name: str) -> Dict[str,str]: | |
""" | |
Read a property file with 1 key/value per line - no multiline supported | |
Multiple lines with the same key would return the last line | |
""" | |
with open(file_name) as f: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Definition for singly-linked list. | |
# class ListNode: | |
# def __init__(self, val=0, next=None): | |
# self.val = val | |
# self.next = next | |
class Solution: | |
def removeNthFromEnd(self, head: Optional[ListNode], n: int) -> Optional[ListNode]: | |
current, nth = head, ListNode(val=None, next=head) | |
while current: | |
current = current.next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def minDistance(self, word1: str, word2: str) -> int: | |
memo = {} | |
def dfs(offset1, offset2): | |
if (offset1, offset2) in memo: | |
return memo[(offset1, offset2)] | |
if len(word1) == offset1 or len(word2) == offset2: | |
return abs((len(word1)-offset1)-(len(word2)-offset2)) | |
if word1[offset1] == word2[offset2]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import * | |
from sys import * | |
from collections import * | |
from math import * | |
def checkgraph(edges, n, m): | |
neighbors = defaultdict(set) | |
for node1, node2 in edges: | |
neighbors[node1].add(node2) | |
neighbors[node2].add(node1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def minimum_cost_array(red, blue, blue_cost): | |
assert len(red) == len(blue), f"red and blue lines have different sizes" | |
result = [0] | |
is_blue = False | |
for r, b in zip(red, blue): | |
cost_blue = b if is_blue else b + blue_cost | |
cost_red = r | |
if cost_blue <= cost_red: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import lru_cache | |
class Solution: | |
def change(self, amount: int, coins: List[int]) -> int: | |
scoins = sorted(coins, reverse=True) | |
@lru_cache | |
def dfs(amt, index): | |
if amt == 0: return 1 | |
if amt < 0: return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import lru_cache | |
class Solution: | |
def change(self, amount: int, coins: List[int]) -> int: | |
@lru_cache | |
def dfs(amt): | |
if amt == 0: return 1 | |
if amt < 0: return 0 | |
return sum(dfs(amt - coins[i]) for i in range(len(coins))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for any natural number return the ZECK - | |
# Given N - return non consecutive list of fibonacci numbers that sum up to N | |
# 0 1 1 2 3 5 8 13 21 34 55 89 | |
# 10 -> [8 2] | |
# 62 -> [2, 5, 55], |
NewerOlder