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
SET SESSION sql_mode= 'ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' |
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
public class StackWithMin extends Stack<Integer> { | |
Stack<Integer> minStack; | |
private int minValue; | |
public StackWithMin() { | |
super(); | |
minStack = new Stack<Integer>(); | |
} | |
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
public class Node { | |
public Node next; | |
public Node nextMinimum; | |
public int data; | |
public Node(int value) { | |
this.data = value; | |
} | |
} |
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 Node { | |
Node next; | |
Node prev; | |
int data; | |
public Node(int value) { | |
this.data = value; | |
} | |
} |
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
public void partitionList(Node head, int value) { | |
Node small = null; | |
Node smallItr = null; | |
Node great = null; | |
Node greatItr; | |
while (head != null) { | |
if (head.data < value) { | |
if (smallItr == null) { | |
small = smallItr = head; | |
} |
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
public void fillZeros(int[][] matrix) { | |
int numRows = matrix.length; | |
int numCols = matrix[0].length; | |
boolean[] rows = new boolean[numRows]; | |
boolean[] cols = new boolean[numCols]; | |
for (int i = 0; i < numRows; i++) { | |
for (int j = 0; j < numCols; j++) { | |
if (matrix[i][j] == 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
public Node findLastKth(Node head, int k) { | |
// Assume k > 0 | |
if (k <= 0 || head == null) | |
return null; | |
Node current = head; | |
Node runner = current; | |
while (k > 0 && runner != null) { | |
k--; | |
runner = runner.next; |
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 Node { | |
Node next = null; | |
char data; | |
public Node(char c) { | |
data = c; | |
} | |
} | |
// FOLLOW UP -> FOLW UP |
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
public boolean isPermutation(String source, String dest) { | |
// is source a permutation of dest? | |
if (source == null || dest == null) | |
return false; | |
if (source.length() != dest.length() | |
return false; | |
while (source.length() > 0) { | |
// If they somehow |
NewerOlder