Skip to content

Instantly share code, notes, and snippets.

View willwangcc's full-sized avatar
⚙️
workflow

Will willwangcc

⚙️
workflow
View GitHub Profile
# Time: O(row * len(word))
# Space: O(len(sentence) * len(word))
class Solution(object):
def wordsTyping(self, sentence, rows, cols):
"""
:type sentence: List[str]
:type rows: int
:type cols: int
:rtype: int
# https://github.com/WillWang-X/leetcode-with-illustrations/blob/master/407.trapping-rain-water-ii.ipynb
# https://kyso.io/will/407-trapping-rain-water-ii
'''
Solution1: queue and do like siege(queue by layers and layers)
Solution2: priority queue and do like flooding (the water level rises gradually)
'''
# Time: O(n^2)
# Space: O(n^2)
<!DOCTYPE html>
<html>
<head><meta charset="utf-8" />
<title>407-trapping-rain-water-ii</title><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<style type="text/css">
/*!
*
* Twitter Bootstrap
@willwangcc
willwangcc / crawlPy3.py
Last active March 8, 2018 10:24
a simple python3 crawler used to crawl comments from Weibo
'''
weibo: https://m.weibo.cn/status/4207322874498504
screenshot: https://i.imgur.com/KdlmcoP.png
screenshot: https://i.imgur.com/KdlmcoP.png
eference: https://www.bilibili.com/video/av18151847/
'''
import requests, re
def sina():
# https://repl.it/@WillWang42/792NumberOfMatchingSubsequences
###################################################
# Time: O(len(S) + len(words)*w*log(S/26)) where w is average length of words
# Space: O(len(S))
"""
0123456789
S = "abacbdaecd"
words = ["a", "bb", "acd", "ace","aea"]
//Java program to illustrate the
// concept of inheritance
// https://www.geeksforgeeks.org/inheritance-in-java/
// Demo: https://repl.it/@WillWang42/Java-Class-Inheritance-Demo
public class Main
{
// base class
static class ClassA
{
# Time: O(n^2) where n is the length of subarrays
# Space: O(1)
'''
A = [2, 1, 4, 3]
L = 2
R = 3
-----
the # of subarrays that starts with A[i]
2
2,1
// https://www.sitepoint.com/simple-inheritance-javascript/
// https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Inheritance
// https://repl.it/@WillWang42/JavaScript-Inheritance-Demo
// https://gist.github.com/WillWang-X/a3791dac74fd738e94d025c80699a47e
var ClassA = function() {
this.name = "class A";
}
ClassA.prototype.print = function() {
# Time: O(n)
# Space: O(n)
# 76. Minimum Window Substring
'''
t = "ABC"
s = "ADOBECODEBANC"
d = {"A":1, "B":1, "C":1}
------
d = {"A":1, "B":0, "C":0}
counter = 0
# Time: O(n)
# Space: O(1)
# 340. Longest Substring with At Most K Distinct Characters
'''
01234
"eceba" k = 2
--------------
visited = {e:1,c:0,b:1}
01234
eceba