Skip to content

Instantly share code, notes, and snippets.

@daifu
daifu / longestValidParentheses.java
Created June 22, 2013 06:21
Longest Valid Parentheses - leetcode
/*
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.
For "(()", the longest valid parentheses substring is "()", which has length = 2.
Another example is ")()())", where the longest valid parentheses substring is "()()", which has length = 4.
Algorithm time complexity is O(n), and space complexity is O(n)
Basic algrithm is to keep track of the longest matched paramthesis.
But we need to separate the valid substring, which have 2 special cases: ())()() and ()()(((), and others(whole string
@krishnanraman
krishnanraman / gist:5224937
Last active December 15, 2015 07:39
Pail Example
Pail example:
Writejob: Partition numbers [1..100] into two directories - belowfifty & abovefifty.
Further, create 7 subdirectories under each, based on number mod 7.
So a number like 62 would end up in the location "abovefifty/6".
Readjob: Read the subdirectories "belowfifty/3" & "abovefifty/0"
RESULTS:
$ tree pailtest
@nuxlli
nuxlli / sublime_text_2_useful_shortcuts.md
Created September 9, 2011 18:51 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@mbostock
mbostock / .block
Last active February 2, 2021 04:59
Build Your Own Graph!
license: gpl-3.0
redirect: https://observablehq.com/@d3/build-your-own-graph