This file contains 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
/* | |
* https://www.interviewstreet.com/challenges/dashboard/#problem/4ff1484963063 Zombie March | |
* http://www.17sotv.com/ 17sotv电影天堂 | |
*/ | |
#include <stdio.h> | |
#include <string.h> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; |
This file contains 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
#!/usr/bin/python | |
""" | |
greedy algorithm | |
http://www.17sotv.com/ 17sotv电影天堂 | |
""" | |
import sys | |
def solve(used, edges, k): |
This file contains 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
/* | |
* http://www.17sotv.com/ 17sotv电影天堂 | |
*/ | |
#include <vector> | |
using namespace std; | |
#include <stdint.h> | |
class MyStack |
This file contains 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
extern "C" | |
{ | |
#include <pthread.h> | |
} | |
class MyRWLock | |
{ | |
public: | |
MyRWLock(); | |
~MyRWLock(); |
This file contains 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
#!/usr/bin/python | |
import random | |
def quick_sort_(buf, left, right): | |
ll, rr = left, right | |
pivot = random.choice(buf[left : right + 1]) | |
while left <= right: | |
while buf[left] < pivot: | |
left += 1 |
This file contains 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
#!/usr/bin/python | |
def get_nth_num(a, b): | |
if len(a) != len(b) or len(a) == 0: | |
return None | |
id_a, id_b = 0, 0 | |
for _ in xrange(len(a)): | |
if a[id_a] <= b[id_b]: | |
tmp = a[id_a] | |
id_a += 1 |
This file contains 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
#!/usr/bin/python | |
def perfect_shuffle_(buf, left, right): | |
len_ = right - left + 1 | |
if len_ == 2: | |
return | |
left_beg = left + len_ / 4 | |
right_beg = left + len_ / 2 | |
shuffle_len = len_ / 4 | |
if len_ % 4 == 0: |
This file contains 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 <tr1/unordered_map> | |
#include <vector> | |
#include <string> | |
#include <algorithm> | |
using namespace std; | |
class Solution { | |
public: | |
vector<vector<int> > threeSum(vector<int> &num) { | |
vector< vector<int> > ret; |
This file contains 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 <algorithm> | |
#include <vector> | |
using namespace std; | |
class Solution { | |
public: | |
void update(int& closest, int& ret, int sum, int target) { | |
int diff = abs(sum - target); | |
if (diff < closest) { | |
closest = diff; |
This file contains 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 <algorithm> | |
#include <vector> | |
#include <string> | |
#include <tr1/unordered_map> | |
using namespace std; | |
class Solution { | |
public: | |
vector<vector<int> > fourSum(vector<int> &num, int target) { | |
vector< vector<int> > ret; |
OlderNewer