Skip to content

Instantly share code, notes, and snippets.

@dosentmatter
dosentmatter / analysis.txt
Last active August 22, 2020 09:12
Leetcode 283. "Move Zeroes" Solutions 2/3 Analysis
I don't think Solution 2 is always better than Solution 3
First of all, it doesn't matter unless n is large, since both are O(n).
For both Solutions 2 and 3, you can skip operations when there are non-zeros at the beginning of the array by doing the following:
For Solution 2, you can skip moving when `lastNonZeroFoundAt == i`
For Solution 3, you can skip swapping when `lastNonZeroFoundAt == cur`
For Solution 2, even if you do a memset, that is an O(n) because it has to write each element to 0.
For Solution 3, we can say that swap is a 3 cost operation since it does 3 writes including the temporary variable.
@dosentmatter
dosentmatter / index.js
Created August 29, 2019 18:14
`antd` `@ant-design/icons` cherry-pick
// Affix
// Alert
export { default as CheckCircleOutline } from '@ant-design/icons/lib/outline/CheckCircleOutline';
export { default as CloseCircleOutline } from '@ant-design/icons/lib/outline/CloseCircleOutline';
export { default as CloseOutline } from '@ant-design/icons/lib/outline/CloseOutline';
export { default as ExclamationCircleOutline } from '@ant-design/icons/lib/outline/ExclamationCircleOutline';
export { default as InfoCircleOutline } from '@ant-design/icons/lib/outline/InfoCircleOutline';
// Avatar
This is Google's cache of https://laubonghaudoi.github.io/dialects/install/mac.html. It is a snapshot of the page as it appeared on Jul 17, 2019 03:14:34 GMT. The current page could have changed in the meantime. Learn more.
Full versionText-only versionView source
Tip: To quickly find your search term on this page, press Ctrl+F or ⌘-F (Mac) and use the find bar.
<!DOCTYPE html>
<html lang="en-us">
<head>
<link href="http://gmpg.org/xfn/11" rel="profile" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
@dosentmatter
dosentmatter / README.md
Last active March 25, 2019 06:13
Parrot Say Cow Say

parrotsaycowsay.html

You can use this method to convert highlighted text in your terminal (such as git diffs, vim, or pygmentize) into formats that are easier to share.

@dosentmatter
dosentmatter / install.bash
Last active February 26, 2019 00:27
Squirrel@0.11.0 macOS jyutping
# You can install manually or use homebrew cask.
brew cask install squirrel
cd ~ || exit
# This will clone a git repo in your ~ directory.
# It will also install the set of preset schemas and the jyutping schema.
curl -fsSL https://git.io/rime-install | bash -s -- :preset jyutping
# This will overwrite your current ~/Library/Rime/default.custom.yaml
@dosentmatter
dosentmatter / cantoeb-min.js
Last active November 27, 2017 04:55
CantoDict Chrome Search Engine Bookmarklet
javascript:!function(){(function(){(function(e,n,t){t=t||"post";var o=document.createElement("form");o.style.display="none",o.method=t,o.action=e;for(var a in n){var c=document.createElement("input");c.name=a,c.value=n[a],o.appendChild(c)}document.body.appendChild(o),o.submit()})("http://www.cantonese.sheik.co.uk/scripts/wordsearch.php%3Flevel=0",{TEXT:"%s",SEARCHTYPE:4,radicaldropdown:0,searchsubmit:"search"})})()}();
@dosentmatter
dosentmatter / tree.py
Last active May 4, 2017 03:18
Random algorithms
from collections import deque
class TreeNode:
def __init__(self, value, children=[]):
self.value = value
self.children = children
def breadth_first_traverse(self):
breadth_first_queue = deque()
breadth_first_queue.append(self)