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
/** | |
* Created by linwei on 9/20/16. | |
*/ | |
class IsSubstring { | |
public boolean isSubstring(String source, String pattern) { | |
if (source == null || pattern == null) { | |
return false; | |
} | |
for (int i = 0; i < source.length(); i++) { |
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 javax.naming.OperationNotSupportedException; | |
import java.util.ArrayList; | |
import java.util.Iterator; | |
/** | |
* Created by linwei on 9/20/16. | |
*/ | |
import javax.naming.OperationNotSupportedException; | |
import java.util.ArrayList; | |
import java.util.Iterator; |
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 javax.naming.OperationNotSupportedException; | |
import java.util.ArrayList; | |
import java.util.Iterator; | |
/** | |
* Created by linwei on 9/20/16. | |
*/ | |
public class MyList extends ArrayList<Character> { | |
@Override | |
public Iterator<Character> iterator() { |
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
class TreeNode { | |
int val; | |
TreeNode* left; | |
TreeNode* right; | |
TreeNode(int val_) : val(val_) {} | |
}; | |
class Solution { | |
int ans = 0; | |
int maxAmp(struct TreeNode* root) { |
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.concurrent.*; | |
import java.util.concurrent.locks.*; | |
import java.io.IOException; | |
/** | |
* Created by jianye on 5/12/16. | |
* Modified by Wei on 5/13/16. | |
*/ | |
import java.util.concurrent.*; | |
import java.util.concurrent.locks.*; |
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
#include <iostream> | |
#include <vector> | |
#include <string> | |
using namespace std; | |
void dfs(string &num, int offset, vector<string> &map, string &solution, vector<string> &result) | |
{ | |
if (solution.size() == num.size()) { | |
//cout << "n" << endl; | |
result.push_back(solution); | |
return; |
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
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
struct comparator | |
{ | |
bool operator() (int a, int b) { | |
return a > b; | |
} | |
}; |
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
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
inline bool comparator(const int &a, const int &b) | |
{ | |
return a < b; | |
} | |
int maintain(vector<int> &v) | |
{ |
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
/* six degree separation */ | |
struct GraphNode | |
{ | |
string name; //name of actors | |
bool visited; //visited | |
vector<GraphNode *> neighbors; //neighbor nodes | |
GraphNode(string n) : name(n), visited(false) {} | |
}; | |
/* find the path */ | |
void bfs_helper(GraphNode *end, queue<vector<GraphNode *>> q, bool &found, vector<GraphNode *> &ret) |
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
/* just show rough idea, can't be compiled */ | |
/* reference */ | |
/* http://m.oschina.net/blog/57529 */ | |
struct Co | |
{ | |
float x_co; | |
float y_co; | |
Co(float x, float y) : x_co(x), y_co(y) {} | |
}; |