http://oj.leetcode.com/problems/flatten-binary-tree-to-linked-list/
Given a binary tree, flatten it to a linked list in-place.
For example, Given
http://oj.leetcode.com/problems/flatten-binary-tree-to-linked-list/
Given a binary tree, flatten it to a linked list in-place.
For example, Given
/** | |
* 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) | |
*/ |
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 =
void fib(int n) { | |
if (n == 0) return 0; | |
if (n == 1) return 1; | |
return fib(n-1) + fib(n-2); | |
} |
#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++) { |
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 |
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 |
//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; |
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] |