Skip to content

Commit 6cde45e

Browse files
author
Jie Feng
committed
haha
2 parents f71b3c2 + 8ea6761 commit 6cde45e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2815
-40
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
<<<<<<< HEAD
12
try.cpp
3+
=======
4+
codeforces/in
5+
>>>>>>> 8ea67614540813d9826e3c029eb36e4cc7116fb2

careercup/5145759489982464.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* =====================================================================================
3+
*
4+
* Filename: 5145759489982464.cpp
5+
*
6+
* Description:
7+
*
8+
* Version: 1.0
9+
* Created: 04/25/2014 12:10:15 AM
10+
* Revision: none
11+
* Compiler: gcc
12+
*
13+
* Author: Jie Feng (http://hey.i-feng.org/), [email protected]
14+
* Organization:
15+
*
16+
* =====================================================================================
17+
*/
18+
19+

careercup/leetcode.h

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
#include <cmath>
2+
#include <set>
3+
#include <list>
4+
#include <unordered_set>
5+
#include <hash_map>
6+
#include <climits>
7+
#include <queue>
8+
#include <vector>
9+
#include <map>
10+
#include <set>
11+
#include <cstdlib>
12+
#include <fstream>
13+
#include <iomanip>
14+
#include <iostream>
15+
#include <sstream> // istringstream buffer(myString);
16+
#include <stack>
17+
#include <algorithm>
18+
#include <cstring>
19+
#include <cassert>
20+
using namespace std;
21+
#define bit(x,i) (x&(1<<i))
22+
#define lowbit(x) ((x)&((x)^((x)-1)))
23+
//#define max(a,b) (a<b?b:a)
24+
//#define abs(x) (x<0?-x:x)
25+
#define IN(i,l,r) (l<i&&i<r)
26+
#define LINR(i,l,r) (l<=i&&i<=r)
27+
#define LIN(i,l,r) (l<=i&&i<r)
28+
#define INR(i,l,r) (l<i&&i<r)
29+
#define F(i,L,R) for (int i = L; i < R; i++)
30+
#define FE(i,L,R) for (int i = L; i <= R; i++)
31+
#define FF(i,L,R) for (int i = L; i > R; i--)
32+
#define FFE(i,L,R) for (int i = L; i >= R; i--)
33+
#define char2Int(c) (c-'0')
34+
#define lastEle(vec) vec[vec.size()-1]
35+
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n))
36+
#define clr(a,x) memset(a,x,sizeof(a))
37+
#define getI(a) scanf("%d", &a)
38+
#define getII(a,b) scanf("%d%d", &a, &b)
39+
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
40+
#define getS(x) scanf("%s", x);
41+
#define SZ(x) ((int)((x).size()))
42+
#define REMAX(a,b) (a)=max((a),(b));
43+
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
44+
#define REMIN(a,b) (a)=min((a),(b));
45+
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
46+
#define ALL(t) t.begin(),t.end()
47+
#define ll long long
48+
#define ull unsigned long long
49+
#define ui unsigned int
50+
#define us unsigned short
51+
#define IOS ios_base::sync_with_stdio(0);
52+
#define pb push_back
53+
#define INF 1001001001
54+
#define PI 3.1415926535897932384626
55+
#define mp make_pair
56+
#define ll long long
57+
#define fi first
58+
#define se second
59+
#define wez(n) int (n); scanf("%d",&(n));
60+
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m));
61+
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k));
62+
inline void pisz(int n) { printf("%d\n",n); }
63+
#define TESTS wez(testow)while(testow--)
64+
#define whileZ int T; getI(T); while(T--)
65+
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
66+
#define printM(a,n,m) F(i,0,n){ F(j,0,m) cout << a[i][j] << ' '; cout << endl;}
67+
#define printV(a) printA(a,0,a.size()-1);
68+
#define printVV(a) F(i,0,a.size()) {F(j,0,a[i].size())cout << a[i][j] << ' '; cout << endl;}
69+
#define MAXN 10000
70+
#define sz(a) int((a).size())
71+
#define pb push_back
72+
#define all(c) (c).begin(),(c).end()
73+
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
74+
#define present(c,x) ((c).find(x) != (c).end())
75+
#define cpresent(c,x) (find(all(c),x) != (c).end())
76+
typedef int elem_t;
77+
typedef vector<int> vi;
78+
typedef vector<vi> vvi;
79+
typedef pair<int,int> ii;
80+
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
81+
template<typename T> ostream& operator<<(ostream &s,vector<T> t){F(i,0,SZ(t))s<<t[i]<<" ";return s; }
82+
int gcd(int a,int b){return a?gcd(b%a,a):b;}
83+
ll gcd(ll a,ll b){return a?gcd(b%a,a):b;}
84+
ll powmod(ll a,ll p,ll m){ll r=1;while(p){if(p&1)r=r*a%m;p>>=1;a=a*a%m;}return r;}
85+
const int fx[4][2] = {{0,1}, {1,0}, {0,-1}, {-1,0}};
86+
using namespace std;
87+
struct TreeNode {
88+
int val;
89+
TreeNode *left;
90+
TreeNode *right;
91+
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
92+
};
93+
94+
struct ListNode {
95+
int val;
96+
ListNode *next;
97+
ListNode(int x) : val(x), next(NULL) {}
98+
};
99+
100+
struct Interval {
101+
int start;
102+
int end;
103+
Interval() : start(0), end(0) {}
104+
Interval(int s, int e) : start(s), end(e) {}
105+
};
106+
107+
void printIntervals(vector<Interval> i){
108+
F(j,0,i.size()){
109+
cout << i[j].start << ' ' << i[j].end << endl;
110+
}
111+
}
112+
void printTree(TreeNode* cur){
113+
if (cur == NULL) return;
114+
cout << cur->val << ' ';
115+
116+
if (cur->left == NULL) cout << "NULL" << ' ';
117+
else {
118+
cout << cur->left->val << ' ';
119+
}
120+
121+
if (cur->right == NULL) cout << "NULL" << endl;
122+
else {
123+
cout << cur->right->val << endl;
124+
}
125+
printTree(cur->left);
126+
printTree(cur->right);
127+
}
128+
void addNode(ListNode* &head, int x){
129+
ListNode *a = new ListNode(x);
130+
if (head == NULL){
131+
head = a;
132+
}else{
133+
a->next = head;
134+
head = a;
135+
}
136+
}
137+
void printList(ListNode* head){
138+
while(head != NULL){
139+
cout << head->val << ' ';
140+
head = head->next;
141+
}
142+
cout << endl;
143+
}

careercup/main

78.9 KB
Binary file not shown.

careercup/main.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include "leetcode.h"
2+
void sort_like_wave(vector<int>& a){
3+
bool rise = false;
4+
for (int i = 0; i < a.size()-1; i++){
5+
if (rise){
6+
if (a[i] > a[i+1]) swap(a[i], a[i+1]);
7+
}else{
8+
if (a[i+1] > a[i]) swap(a[i], a[i+1]);
9+
}
10+
}
11+
}
12+
int min_seq_larger_than_sum(vector<int> &a, int sum){
13+
int L = 0, R = 0, tempSum = a[0], minSeq = INT_MAX;
14+
while(R < a.size()){
15+
if (tempSum > sum){
16+
minSeq = min(R-L+1, minSeq);
17+
tempSum -= a[L];
18+
L++;
19+
} else{
20+
R++;
21+
if (R < a.size()){
22+
tempSum += a[R];
23+
}else break;
24+
}
25+
}
26+
return (minSeq == INT_MAX? -1: minSeq);
27+
}
28+
int main()
29+
{
30+
int num[] = {2,1,1,4,3,6};
31+
vector<int> vnum(num, num+sizeof(num)/4);
32+
cout << min_seq_larger_than_sum(vnum, 8) << endl;
33+
}

careercup/main.o

128 KB
Binary file not shown.

careercup/sort_array_like_wave

78.4 KB
Binary file not shown.

careercup/sort_array_like_wave.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "leetcode.h"
2+
void sort_like_wave(vector<int>& a){
3+
bool rise = false;
4+
for (int i = 0; i < a.size()-1; i++){
5+
if (rise){
6+
if (a[i] > a[i+1]) swap(a[i], a[i+1]);
7+
}else{
8+
if (a[i+1] > a[i]) swap(a[i], a[i+1]);
9+
}
10+
}
11+
}
12+
int main()
13+
{
14+
int num[] = {10,1,2,7,6,1,5};
15+
vector<int> vnum(num, num+sizeof(num)/4);
16+
sort_like_wave(vnum);
17+
printV(vnum);
18+
}

careercup/sort_array_like_wave.o

126 KB
Binary file not shown.

codeforces/.427D.cpp.swp

20 KB
Binary file not shown.

0 commit comments

Comments
 (0)