Skip to content

Instantly share code, notes, and snippets.

Amit Saurav amitsaurav

View GitHub Profile
@amitsaurav
amitsaurav / MinimalBalancedTree.java
Last active Nov 28, 2016
A balanced tree with minimal rebalances.
View MinimalBalancedTree.java
package trees;
import java.util.LinkedList;
import java.util.Queue;
/**
* There are bugs around odd and even array length and last element being not added but this is the
* general structure of the code.
*
* @author amitsaurav
@amitsaurav
amitsaurav / ListOfLists.java
Created Nov 23, 2016
List of Lists iterator.
View ListOfLists.java
package collections;
import java.util.Arrays;
import java.util.List;
/**
* Created by amit.saurav on 11/23/16.
*/
public class ListOfLists <T> {
private final List<List<T>> listOfLists;
@amitsaurav
amitsaurav / Palindrome.java
Last active Nov 22, 2016
Code to generate "Palindrome Cover".
View Palindrome.java
import java.io.*;
import java.util.*;
class Palindrome {
public static void main(String[] args) {
List<String> palindromes = Arrays.asList("gabbag", "baggab");
System.out.println(getShortestCover(palindromes));
}
@amitsaurav
amitsaurav / getPreviousDate.sh
Last active Aug 29, 2015
Get Previous Date in Bash
View getPreviousDate.sh
#!/bin/sh
year=`date +%Y`
month=`date +%m`
day=`date +%d`
isLeap=0
if [ $((year%400)) -eq 0 ]; then
isLeap=1
elif [ $((year%100)) -eq 0 ]; then
@amitsaurav
amitsaurav / boa.js
Created Jan 23, 2014
JQuery script to remove all non-parking/non-travel transactions from Bank Of America credit card transactions view.
View boa.js
jQuery("#transactions tbody tr").each(function() {
var row = jQuery(this);
row.find('td:last').remove();
if(row.text().indexOf("CHEVRON") === -1 && row.text().indexOf("U-PARK") === -1 && row.text().indexOf("GOOD2GO") === -1) {
row.remove();
}
});
jQuery("#transactions tfoot").remove();
You can’t perform that action at this time.