No longer will I be posting code tutorials to my blog, Instead, I’ll be posting them on
Awesome Algorithms
which is a non-profit organization I created that
teaches complex code via animation.
Sort the given array with Heap Sort:
Create a Max Heap with the following array. [-3, 11, 52, 4, 23, 70, 65, 100]
Sort the given array with Merge Sort:
A = [5, 2, 4, 6, 1, 3]
quick_sort(A)
assert(A) == [1, 2, 3, 4, 5, 6]
Sort the given array with Merge Sort:
A = [5, 2, 4, 6, 1, 3]
merge_sort(A)
assert(A) == [1, 2, 3, 4, 5, 6]
Sort the given array with Insertion Sort:
A = [5, 2, 4, 6, 1, 3]
insertion_sort(A)
assert(A) == [1, 2, 3, 4, 5, 6]
Sort the given array with Bubble Sort:
A = [5, 2, 4, 6, 1, 3]
bubble_sort(A)
assert(A) == [1, 2, 3, 4, 5, 6]
Sort the given array with Selection Sort:
A = [5, 2, 4, 6, 1, 3]
selection_sort(A)
assert(A) == [1, 2, 3, 4, 5, 6]
Given an array, rotate it 270 degrees.
For many programming challenges, it is often beneficial to find contiguous sub-sequences
given a sequence. Note, the sequence may represent an array, a string, etc.
Given an array, find contiguous subarrays.
Given an array, create an algorithm which determines the
minimum and maximum sum that can be obtained
from any subarrays.
Given a string, reverse the position of every letter in that string except non-letters.
Given a string containing only I’s and D’s, where I’s represent an increase of 1 between adjacent digits
and D’s represent a decrease of 1 between adjacent digits, create a function named foo which determines
the minimum number formed by digits 1 through 9 that matches that pattern, given that no digits can repeat.
A
partial permutation is known as a P(n,k) problem which means we must select permutations
of size k out of n objects. There are numerous algorithms for calculating partial permutations
but I wanted one that seemed more intuitive.
Count the number of strings of length n=3,
that can be made usinga
,b
, andc
with at most oneb
and twoc
’s allowed.
Most code challenges are based on combinatorics so having an understanding of the fundamentals is
essential. In this problem, we’ll calculate full permutations of a given array.
We will do full permutations by hand with the bottom up approach.
Note, the difference between a full permutation and partial permutation is that in a full permutation,
the number of items selected equals the number of items in the original set.
The insights from this can be used to create code which does this automatically.
Most code challenges are based on combinatorics so having an understanding of the fundamentals is
essential. A partial combination is known as a C(n,k) problem which means we must select combinations
of size k out of n objects.
In this problem, we’ll calculate combinations of a given array.
We will do combinations by hand with the bottom up approach.
The insights from this can be used to create code which does this automatically.
Given a square matrix, calculate the absolute difference between the sums of its diagonals.
You have unlimited $20 dollar bills, unlimited $10 dollar bills, unlimited $5 dollar bills, and unlimited $1 dollar bills.
How many ways can you make change for a $100 dollar bill?
You have three $20 dollar bills, five $10 dollar bills, two $5 dollar bills, and five $1 dollar bills.
How many ways can you make change for a $100 dollar bill?
You have three $20 dollar bills, five $10 dollar bills, two $5 dollar bills, and five $1 dollar bills.
How many ways can you make change for a $100 dollar bill?
Find Middle Node of Double Linked List:
1 <=> 2 <=> 3 <=> 4 <=> 5 <=> 6
Find Middle Node of Single Linked List:
1 => 2 => 3 => 4 => 5 => 6
I support the statement black lives matter
but not the organization Black Lives Matter
.
To emphasize this distinction, I’ll refer to the statement in lowercase and the organization as BLM.