This file contains 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
from lxml import etree as ET | |
from itertools import chain | |
import sys | |
if len(sys.argv) > 1: | |
f = open(sys.argv[1]) | |
else: | |
f = open('x.xml') # default xml file | |
# first, remove namespace |
This file contains 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
import java.util.HashMap; | |
import java.util.Map; | |
/** | |
* Created with IntelliJ IDEA. | |
* User: EDFward | |
* Date: 11/17/13 | |
* Time: 12:52 AM | |
* Happy coding! | |
*/ |
This file contains 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains 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
/* | |
1. first using DP, O(n^2), TLE. | |
2. then try spliting arrays to intervals by | |
taking the maximum reach as the boundary. | |
*/ | |
class Solution { | |
public: | |
int jump(int A[], int n) { | |
if (A[0] == 0 || n == 1) return 0; | |
int iter = 1, intervalEnd = A[0], res = 1; |
This file contains 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
/* | |
1. first tried backtracking, TLE | |
2. 2-dimension DP, accepted. state transition is easy to derive | |
*/ | |
class Solution { | |
public: | |
bool isInterleave(string s1, string s2, string s3) { | |
m = s1.size(); | |
n = s2.size(); | |
if (s3.size() != m+n) return 0; |
This file contains 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
/** | |
* Definition for singly-linked list. | |
* class ListNode { | |
* int val; | |
* ListNode next; | |
* ListNode(int x) { | |
* val = x; | |
* next = null; | |
* } | |
* } |
This file contains 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
""" | |
(C) Mathieu Blondel - 2010 | |
License: BSD 3 clause | |
Implementation of the collapsed Gibbs sampler for | |
Latent Dirichlet Allocation, as described in | |
Finding scientifc topics (Griffiths and Steyvers) | |
""" |
This file contains 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
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.Comparator; | |
import java.util.List; | |
/** | |
* Created with IntelliJ IDEA. | |
* User: EDFward | |
* Date: 12/8/13 | |
* Time: 9:56 PM |
This file contains 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
/* | |
reduced code from 120 lines to 40 lines: | |
no need to build classes like Line and Fraction! | |
it's enough to | |
1. represent lines using only slope since point i | |
is fixed | |
2. use string as the key of hashmap | |
*/ | |
public class Solution { |