This file contains hidden or 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 mysql.connector | |
from mysql.connector import errorcode | |
try: | |
cnx = mysql.connector.connect(user='root', password='******', | |
host='**.**.**.**', | |
database='dbname') | |
except mysql.connector.Error as err: | |
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR: | |
print("Something is wrong with your user name or password") | |
elif err.errno == errorcode.ER_BAD_DB_ERROR: |
This file contains hidden or 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
{ | |
"bold_folder_labels": true, | |
"caret_style": "phase", | |
"color_scheme": "Packages/Color Scheme - Default/Monokai Bright.tmTheme", | |
"fade_fold_buttons": false, | |
"highlight_line": true, | |
"line_padding_bottom": 1, | |
"line_padding_top": 1 | |
} |
This file contains hidden or 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
package Microsoft; | |
import java.util.*; | |
public class Poker { | |
public static class Card { | |
private String suite; | |
private int number; | |
public Card(String suite, int number) { |
This file contains hidden or 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
package Microsoft; | |
import java.util.*; | |
public class Poker { | |
public static class Card { | |
private String suite; | |
private int number; | |
public Card(String suite, int number) { |
This file contains hidden or 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
public static int getDeviation(int[] array, int k){ | |
//error checking | |
if(array == null || array.length ==0 || k <=0) return 0; | |
int maxDeviation = 0; | |
//store max value's index in the current window | |
LinkedList<Integer> maxList = new LinkedList<Integer>(); | |
//store min value's index in the current window | |
LinkedList<Integer> minList = new LinkedList<Integer>(); | |
for(int i =0;i<array.length;i++) { | |
//remove any value which is smaller than current |
This file contains hidden or 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
package LeetCode2015.ExpressionCaculator; | |
import java.nio.charset.CharacterCodingException; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.LinkedList; | |
import java.util.Stack; | |
/** | |
* Created by Trace_route on 7/6/15. |
This file contains hidden or 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
//2015NewWellorderedString | |
public static ArrayList<String> getWellOrderedString(int n){ | |
if(n<=0 || n >26) throw new IllegalArgumentException(); | |
ArrayList<String> ret = new ArrayList<String>(); | |
int size = 1<<26; | |
for(int i =0;i<size;i++){ | |
String str = convertInto(i,n); | |
if(!str.isEmpty()) | |
ret.addAll(getUppercase(str)); | |
} |
This file contains hidden or 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
public static boolean colorNumber(int num){ | |
//error checking | |
if(num<0 ) return false; //never considering negative in this case; | |
HashSet<Long> set = new HashSet<Long>(); //to avoid overflow because int*int is possible overflow; | |
String numStr = String.valueOf(num); | |
for(int i =0;i<numStr.length();i++){ | |
long number = numStr.charAt(i)-'0'; | |
for(int j = i+1;j<numStr.length();j++){ | |
number*=numStr.charAt(j) -'0'; | |
if(set.contains(number)) return false; |
This file contains hidden or 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
package Hired; | |
import java.util.LinkedList; | |
/** | |
* Created by Trace_route on 6/14/15. | |
*/ | |
public class Deviation { | |
public static void find_deviation(int[] v, int d) { | |
// Write your code here |
This file contains hidden or 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
public static LinkedList<LinkedList<Integer>> getPathWithSumBinaryTree(TreeNode root,int sum){ | |
LinkedList<LinkedList<Integer>> ret = new LinkedList<LinkedList<Integer>>(); | |
if(root == null) return ret; | |
getPathHelper(root,ret,sum); | |
return ret; | |
} | |
public static HashMap<Integer,LinkedList<LinkedList<Integer>>> getPathHelper(TreeNode root, LinkedList<LinkedList<Integer>> collector, int sum){ | |
//base | |
if(root == null) return new HashMap<Integer, LinkedList<LinkedList<Integer>>>(); | |
//retrieve left cache and right cache |
NewerOlder