Skip to content

Instantly share code, notes, and snippets.

@El-Sam
El-Sam / coin_change_dp.py
Created May 3, 2018 18:10
A bottom top dynamic programming solution for the Coin Change problem.
def coin_change_dp_bottom_top(amount: int, coins: set):
db = [0] * (amount + 1)
db[0] = 1
for coin in coins:
for i in range(coin, amount + 1):
db[i] += db[i - coin]
return db[amount]
@El-Sam
El-Sam / mergeTwoSortedLinkedLists.java
Created October 13, 2017 21:18
Code to merge two sorted linked lists into one sorted linked list by changing the next pointer.
/*
Merge two linked lists
head pointer input could be NULL as well for empty list
Node is defined as
class Node {
int data;
Node next;
}
*/
@El-Sam
El-Sam / PrintLinkedListInReverse.java
Last active March 2, 2018 14:15
print a linked list in reverse order
/*
Print elements of a linked list in reverse order
head pointer input could be NULL as well for empty list
Node is defined as
class Node {
int data;
Node next;
}
*/
void ReversePrint(Node head) {
@El-Sam
El-Sam / ReverseLinkedList.java
Created October 11, 2017 22:59
Reverse a linked list and return pointer to the head
/*
Reverse a linked list and return pointer to the head
The input list will have at least one element
Node is defined as
class Node {
int data;
Node next;
}
*/
@El-Sam
El-Sam / CompareLinkedList.java
Created October 11, 2017 22:57
Compare two linked lists A and B
/*
Compare two linked lists A and B
Return 1 if they are identical and 0 if they are not.
Node is defined as
class Node {
int data;
Node next;
}
*/
int CompareLists(Node headA, Node headB) {
@El-Sam
El-Sam / remove-docker-containers.md
Created October 4, 2017 12:35 — forked from ngpestelos/remove-docker-containers.md
How to remove unused Docker containers and images
  1. Delete all containers

     $ docker ps -q -a | xargs docker rm
    

-q prints only the container IDs -a prints all containers

Notice that it uses xargs to issue a remove container command for each container ID

  1. Delete all untagged images
@El-Sam
El-Sam / gist:fc5cdcf8e515ab48c90e5d5ac55a5eb9
Created March 15, 2017 15:43 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@El-Sam
El-Sam / API.md
Created March 10, 2017 12:14 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method: