Skip to content

Instantly share code, notes, and snippets.

View chengsieuly's full-sized avatar

Cheng Ly chengsieuly

View GitHub Profile
@chengsieuly
chengsieuly / deque.js
Last active September 6, 2016 21:00
Deque()
// Less optimal implementation
class Deque {
constructor() {
this.deque = [];
}
addToFront(item) {
this.deque.unshift(item);
}
@chengsieuly
chengsieuly / dna_sequence_algorithm.txt
Created July 22, 2016 20:18
Find if pattern exist in DNA sequence
DNA Sequence
The information in DNA is stored as a sequence of four chemical bases (adenine, guanine, cytosine, and thymine).
These four bases are often represented by the letters A, G, C and T. Sequences of DNA, then, can be represented by
strings of these characters.
Imagine the task of checking whether a given genome (long string of "ACGT" bases) contains a specified gene
(shorter sequence of bases) as a substring. One way to do this is to loop over every index in the genome,
and try to match the gene sequence from each location. This will take (in the worst case) a number of steps
proportional to the length of the genome multiplied by the length of the gene sequence.