Skip to content

Instantly share code, notes, and snippets.

import java.util.*;
public class Solution {
/*
comopute the time spent from (x1, y1) to (x2, y2)
*/
public static int timeConsumed(int x1, int y1, int x2, int y2) {
int moveSpeed = 100;
if (x1 == x2) {
return Math.abs(y1 - y2) * moveSpeed;
@gaohao
gaohao / README.md
Created March 17, 2013 05:42 — forked from mbostock/.block

Click to add nodes! Nodes near the cursor will be linked to the new node.

D3's force layout uses the Barnes–Hut approximation to compute repulsive charge forces between all nodes efficiently. Links are implemented as geometric constraints on top of position Verlet integration, offering greater stability. A virtual spring between each node and the center of the chart prevents nodes from drifting into space.

@gaohao
gaohao / Punctuation
Created February 3, 2013 05:45
Punctuation, English -> Chinese
+  plus 加号;正号
-  minus 减号;负号
± plus or minus 正负号
× is multiplied by 乘号
÷ is divided by 除号
= is equal to 等于号
≠ is not equal to 不等于号
≡ is equivalent to 全等于号
≌ is equal to or approximately equal to 等于或约等于号
≈ is approximately equal to 约等于号
@gaohao
gaohao / gist:4256219
Created December 11, 2012 05:57
Delete the nth last element from a singly linked list
1. Have two pointers ptr1 and ptr2 pointing to head of linked list
2. Traverse one pointer say ptr2 to distance n from head
3. Now, traverse both
4. When ptr2 reaches the tail, ptr1 is at distance "n" from the tail of linked list
recursive?
@gaohao
gaohao / sublime_text_2_useful_shortcuts_1.md
Created November 15, 2012 06:30 — forked from nuxlli/sublime_text_2_useful_shortcuts.md
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