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
from time import sleep | |
from tornado.httpserver import HTTPServer | |
from tornado.ioloop import IOLoop | |
from tornado.web import Application, asynchronous, RequestHandler | |
from multiprocessing.pool import ThreadPool | |
_workers = ThreadPool(10) | |
def run_background(func, callback, args=(), kwds={}): | |
def _callback(result): |
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
// | |
// main.cpp | |
// cc4_3 | |
// | |
// Created by gsw on 12-5-9. | |
// Copyright (c) 2012年 __MyCompanyName__. All rights reserved. | |
// | |
/****************************************************************************** | |
* Given a sorted (increasing order) array, write an algorithm to create a |
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
/***************************************************************** | |
Implement a function to check if a tree is balanced | |
For the purposes of this question, a balanced tree is | |
defined to be a tree such that no two leaf Nodes differ | |
in distance from the root by more than one | |
******************************************************************/ | |
#include <iostream> |
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
// | |
// main.cpp | |
// cc3_3 | |
// | |
// Created by kandia on 12-5-3. | |
// Copyright (c) 2012年 kandia. All rights reserved. | |
// | |
/******************************************************************************* | |
* Imagine a (literal) stack of plates If the stack gets too high, it might |
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> | |
using namespace std; | |
struct node | |
{ | |
int data; | |
node *next; | |
node(): data(0), next(NULL){} | |
}; |
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
/********************************************************************** | |
1.Write code to remove duplicates from an unsorted linked list | |
FOLLOW UP | |
How would you solve this problem if a temporary buffer is not allowed? | |
2.Implement an algorithm to find the nth to last element of | |
a singly linked list. (method: find_n()) | |
***********************************************************************/ |
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
/********************************************************************* | |
Write an algorithm such that if an element in an MxN matrix is 0, | |
its entire row and column is set to 0 | |
**********************************************************************/ | |
#include <iostream> | |
using namespace std; | |
const int M = 4, N = 4; |
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
/* | |
Q: Given an image represented by an NxN matrix, | |
where each pixel in the image is 4 bytes, write | |
a method to rotate the image by 90 degrees | |
Can you do this in place? | |
*/ | |
/* | |
C++传递二维数组比较麻烦 |
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 <cstdio> | |
#include <cstring> | |
#include <cstdlib> | |
using namespace std; | |
void replace(char *str) | |
{ | |
int n = 0; | |
int i; | |
for(i = 0; str[i] != '\0'; 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
#include <iostream> | |
#include <string> | |
using namespace std; | |
bool is_anagram(const string &str1, const string &str2) | |
{ | |
if(str1.size() != str2.size()) | |
return false; | |
int cnt1[256] = {0}; | |
int cnt2[256] = {0}; |
NewerOlder