Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@berkayk
berkayk / Mysql invalid default value error.
Created November 27, 2017 12:05
This query fixes current session's invalid default value error.
SET SESSION sql_mode= 'ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
@berkayk
berkayk / 0_reuse_code.js
Created July 26, 2017 07:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
public class StackWithMin extends Stack<Integer> {
Stack<Integer> minStack;
private int minValue;
public StackWithMin() {
super();
minStack = new Stack<Integer>();
}
public class Node {
public Node next;
public Node nextMinimum;
public int data;
public Node(int value) {
this.data = value;
}
}
class Node {
Node next;
Node prev;
int data;
public Node(int value) {
this.data = value;
}
}
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;
}
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) {
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;
class Node {
Node next = null;
char data;
public Node(char c) {
data = c;
}
}
// FOLLOW UP -> FOLW UP
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