This file contains hidden or 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
# 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 |
This file contains hidden or 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
# 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) |
This file contains hidden or 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
<!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 |
This file contains hidden or 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
''' | |
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(): |
This file contains hidden or 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
# 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"] |
This file contains hidden or 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
//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 | |
{ |
This file contains hidden or 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
# 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 |
This file contains hidden or 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
// 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() { |
This file contains hidden or 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
# 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 |
This file contains hidden or 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
# 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 |