Skip to content

Instantly share code, notes, and snippets.

@guolinaileen
guolinaileen / README.md
Created September 5, 2018 02:59 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

All hex value from 100% to 0% alpha:

@guolinaileen
guolinaileen / 4Sum.cpp
Created March 27, 2013 06:01
if wishing to speed up, hashmap should be used because we cann't ensure that all the results are in included. if using hashmap, fetching time would be O(1) C++ version can be improved just like java version did.
class Solution {
public:
vector<vector<int> > fourSum(vector<int> &num, int target) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
vector<vector<int> > result;
if(num.size()<4) return result;
sort(num.begin(), num.end());
for(int i=0; i<=num.size()-4; i++)
{
public class Solution {
public int minCut(String s) {
// Start typing your Java solution below
// DO NOT write main() function
if(s.length()==0) return 0;
int [] dp=new int [s.length()+1];
for(int i=s.length(); i>=0; i--)
{
dp[i]=s.length()-i;
}
public class Solution {
public ArrayList<ArrayList<String>> partition(String s) {
// Start typing your Java solution below
// DO NOT write main() function
ArrayList<ArrayList<String>> list=new ArrayList<ArrayList<String>>();
int length=s.length();
if(length==0) return list;
part(s, 0, new ArrayList<String>(), list);
return list;
}
@guolinaileen
guolinaileen / Surrounded Regions.java
Last active December 14, 2015 22:09
Java is too slow to pass the large test.
public class Solution {
public void solve(char[][] board) {
// Start typing your Java solution below
// DO NOT write main() function
if( board==null || board.length==0 || board[0].length==0) return;
int m=board.length;
int n=board[0].length;
for(int i=0; i<m; i++)
{
if(board[i][0]=='O') DFS(board, i, 0);
public class Solution {
public int numDistinct(String S, String T) {
// Start typing your Java solution below
// DO NOT write main() function
int n=S.length();
int m=T.length();
if(n==0) return 0;
int d[][]=new int [n][m];
for(int i=0; i<n; i++)
{
public class Solution {
public void sortColors(int[] A) {
// Start typing your Java solution below
// DO NOT write main() function
int end=A.length;
int start=-1;
for(int i=0; i<end; i++)
{
if(A[i]==0)
{
public class Solution {
public String getPermutation(int n, int k) {
// Start typing your Java solution below
// DO NOT write main() function
if(k<0) return "";
ArrayList<Integer>num=new ArrayList<Integer>();
int sum=1;
for(int i=1; i<=n; i++)
{
sum*=i; num.add(i);
public class Solution {
public ArrayList<ArrayList<Integer>> permuteUnique(int[] num) {
// Start typing your Java solution below
// DO NOT write main() function
return permutation( num, num.length-1, new HashSet<ArrayList<Integer>>());
}
ArrayList<ArrayList<Integer>> permutation(int [] num, int end, HashSet<ArrayList<Integer>> set)
{
ArrayList<ArrayList<Integer>> result=new ArrayList<ArrayList<Integer>> ();
if(end<0)
public class Solution {
public ArrayList<ArrayList<Integer>> permute(int[] num) {
// Start typing your Java solution below
// DO NOT write main() function
return permutation( num, num.length-1);
}
ArrayList<ArrayList<Integer>> permutation(int [] num, int end)
{
ArrayList<ArrayList<Integer>> result=new ArrayList<ArrayList<Integer>> ();
if(end<0)