Notes here
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in range(len(array_to_sort),0,-1): | |
for j in range(i-1): | |
if (array_to_sort[j] > array_to_sort[j+1]): | |
temp = array_to_sort[j]; | |
array_to_sort[j] = array_to_sort[j+1]; | |
array_to_sort[j+1] = temp; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BITS = ('0', '1') | |
ASCII_BITS = 8 | |
def bit_list_to_string(b): | |
"""converts list of {0, 1}* to string""" | |
return ''.join([BITS[e] for e in b]) | |
def seq_to_bits(seq): | |
return [0 if b == '0' else 1 for b in seq] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Decodes Base64 | |
#include <openssl/bio.h> | |
#include <openssl/evp.h> | |
#include <string.h> | |
#include <stdio.h> | |
int calcDecodeLength(const char* b64input) { //Calculates the length of a decoded base64 string | |
int len = strlen(b64input); | |
int padding = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start on runlevel [2345] | |
stop on runlevel [06] | |
setuid devuser #don't run the process as root. You are asking for trouble if you do | |
setgid devuser | |
env NODEFOLDER=/home/dev/node-script | |
script | |
chdir $NODEFOLDER |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start on runlevel [2345] | |
stop on runlevel [06] | |
setuid devuser | |
setgid devuser | |
exec /usr/local/bin/uwsgi --master --socket 127.0.0.1:3031 --pythonpath "/home/dev/python-script" --file "/home/dev/python-script/script.py" --callable app --processes 20 --virtualenv "/home/dev/.virtualenvs/python-script" --enable-threads | |
start on startup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include "mergesort.c" | |
using namespace std; | |
int main(int argc, char** argv) { | |
int num; | |
cout << "How many numbers do you want to sort: "; | |
cin >> num; | |
int a[num]; | |
for (int i = 0; i < num; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void fib(int n) { | |
if (n == 0) return 0; | |
if (n == 1) return 1; | |
return fib(n-1) + fib(n-2); | |
} |
http://oj.leetcode.com/problems/word-search/
Given a 2D board and a word, find if the word exists in the grid.
The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once.
For example, Given board =
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* In an interview, the following questions should be asked: | |
* (1) What happens if k is longer than the list size | |
* (2) Edge cases (if head is NULL and k may be zero) | |
* | |
* Analysis: (where n is the number of nodes in the list) | |
* Time: O(n) | |
* Space: O(1) | |
*/ |
OlderNewer