Skip to content

Instantly share code, notes, and snippets.

View binfeng's full-sized avatar
🎯
Focusing

Alex binfeng

🎯
Focusing
  • UIUC
  • Urbana-Champaign
View GitHub Profile
public class Solution {
/**
* @param s : A string
* @return : The length of the longest substring
* that contains at most k distinct characters.
*/
public int lengthOfLongestSubstringKDistinct(String s, int k) {
// write your code here
if(s == null || s.length() == 0 || k == 0){
return 0;
@binfeng
binfeng / autopush.sh
Created June 11, 2015 07:45
Auto commit and push to Github (experimental)
#!/bin/bash
#eval "$(ssh-agent -s)"
#SERVICE='ssh-agent'
#if ps ax | grep -v grep | grep $SERVICE > /dev/null
#then
# :
# #echo "$SERVICE service running, everything is fine"
#else
@binfeng
binfeng / q_example.js
Last active August 29, 2015 14:04 — forked from Heshyo/q_example.js
// Q sample by Jeff Cogswell
/*===========
We want to call these three functions in sequence, one after the other:
First we want to call one, which initiates an ajax call. Once that ajax call
is complete, we want to call two. Once two's ajax call is complete, we want to call three.
BUT, we don't want to just call our three functions in sequence, as this quick
demo will show. Look at this sample function and think about what order
public class HelloYaml {
@SuppressWarnings("unchecked")
public static void main(String[] args) throws FileNotFoundException {
Yaml yaml = new Yaml();
System.out.println(yaml.dump(yaml.load(new FileInputStream(new File(
"hello_world.yaml")))));
Map<String, Map<String, String>> values = (Map<String, Map<String, String>>) yaml
.load(new FileInputStream(new File("hello_world.yaml")));
test