Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

bobfang1992

🏠
Working from home
View GitHub Profile
View threadapi.json
// 20210306225038
// https://duibiao-1298595392.ap-east-1.elb.amazonaws.com/api/threads/?category=6
{
"results": [
{
"id": 66,
"category": 6,
"title": "How to create a time_point object with year month day?",
"replies": 0,
@bobfang1992
bobfang1992 / word_break.java
Last active Jan 10, 2021
mock_interview_3
View word_break.java
/*
s = "applepenapple" dictionary = ["apple", "pen"]
s = "apple" + "pen" + "apple"
return True
s = "appplepearapple" dictionary = ["apple", "pen"]
return False
View mock_interview_2.txt
//
//Given two sequences pushed and popped with distinct values,
//return true if and only if this could have been the result of a sequence of push and pop operations on an initially empty stack.
//Example 1:
//Input: pushed = [1,2,3,4,5], popped = [4,5,3,2,1]
//Output: true
//Explanation: We might do the following sequence:
@bobfang1992
bobfang1992 / 1265.py
Created Jan 2, 2021
Mock Interveiw 1--1265. Print Immutable Linked List in Reverse
View 1265.py
// Print Immutable Linked List in Reverse
// immutable linked list, print out all values of each node in reverse
// APIs:
// ImmutableListNode: An interface of immutable linked list, you are given the head of the list.
// You need to use the following functions to access the linked list (you can't access the ImmutableListNode directly):
// ImmutableListNode.printValue(): Print value of the current node.
// ImmutableListNode.getNext(): Return the next node.
# getNext() -> ImmutableListNode or None
View 1379.py
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def getTargetCopy(self, original: TreeNode, cloned: TreeNode, target: TreeNode) -> TreeNode:
val = target.val
View 84.py
class Solution:
def largestRectangleArea(self, heights: List[int]) -> int:
stack = [-1]
result = 0
heights.append(0)
for i in range(len(heights)):
while stack and heights[stack[-1]] > heights[i]:
h = heights[stack.pop()]
w = i - stack[-1] - 1
View 289.py
class Solution:
def gameOfLife(self, board: List[List[int]]) -> None:
"""
Do not return anything, modify board in-place instead.
"""
m = len(board)
if m == 0:
return
n = len(board[0])
View uvicorn_sticky_session.py
from fastapi import FastAPI
import uuid
app = FastAPI()
COM_API_OBJECT = {}
@app.get("/create")
async def create():
@bobfang1992
bobfang1992 / clear_db.sql
Created Aug 13, 2020
Delete every table in PG
View clear_db.sql
DO $$ DECLARE
r RECORD;
BEGIN
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP
EXECUTE 'DROP TABLE ' || quote_ident(r.tablename) || ' CASCADE';
END LOOP;
END $$;
View hash_table.md

key - value mapping

{
  "name": "Bob"
  "age": 28,
  "sex": "male"
}