Skip to content

Instantly share code, notes, and snippets.

View hyfrey's full-sized avatar
🏂

hyfrey

🏂
  • Shanghai, Hangzhou
View GitHub Profile
@hyfrey
hyfrey / 1004.c
Created September 9, 2012 20:06
pat 1004
#include <stdio.h>
#include <stdlib.h>
typedef struct node {
struct node *child;
struct node *brother;
} node_t;
void count_leaf(node_t *node, int *counts, int height, int *depth)
{
@hyfrey
hyfrey / 1020.cpp
Created September 10, 2012 15:30
pat 1020
#include <cstdio>
#include <queue>
using namespace std;
struct node_t {
node_t *left;
node_t *right;
int data;
};
@hyfrey
hyfrey / 1020.c
Created September 11, 2012 04:18
pat 1020
#include <stdlib.h>
#include <stdio.h>
typedef struct node {
int data;
struct node *left;
struct node *right;
} node_t;
typedef struct queue {
@hyfrey
hyfrey / 1014.cpp
Created September 12, 2012 13:20
pat 1014
#include <stdlib.h>
#include <stdio.h>
#define MAX_TIME 9*60
int main(){
int N, M, K, Q;
scanf( "%d %d %d %d", &N, &M, &K, &Q );
int **win = (int **)malloc(sizeof(int *)*N);
int i;
@hyfrey
hyfrey / 1037.cpp
Created September 13, 2012 06:31
pat 1037
#include <cstdio>
#include <algorithm>
using namespace std;
void quicksort( int *num, int start, int end){
if( start >= end ){
return;
}
int temp = num[start];
@hyfrey
hyfrey / 1032.c
Created September 13, 2012 08:22
pat 1032
#include <stdio.h>
int node[100010];
char hash[100010];
int main()
{
int start_a, start_b;
int i, n;
int a, b;
@hyfrey
hyfrey / 1029.cpp
Created September 13, 2012 14:15
pat 1029
#include <cstdio>
long int s1[1000010];
long int s2[1000010];
int main()
{
int M,N;
scanf("%d", &M);
for (int i = 0; i < M; i++) {
@hyfrey
hyfrey / cwmw.cpp
Created September 17, 2012 14:20
leetcode: Container With Most Water
class Solution {
public:
int max(int a, int b) {
return a > b ? a : b;
}
int min(int a, int b) {
return a < b ? a : b;
}
@hyfrey
hyfrey / vf.cpp
Created September 24, 2012 06:38
Cpp Virtual Function
#include <iostream>
using namespace std;
/*
######################################################################################################
######################################################################################################
1
*/
@hyfrey
hyfrey / UniqueBinarySearchTrees.cpp
Created September 25, 2012 03:54
leetcode Unique Binary Search Trees
/*
Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?
For example,
Given n = 3, there are a total of 5 unique BST's.
1 3 3 2 1
\ / / / \ \
3 2 1 1 3 2