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
struct TrafficCongestionDivTwo { | |
long long theMinCars(int treeHeight) { | |
int i; | |
Int ans = 1LL; | |
for (i = treeHeight; i >= 1; i -= 2) { | |
ans += (Int) (pow(2, i) / 2); | |
} | |
if (treeHeight % 2 != 0) ans -= 1LL; |
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
struct LISNumberDivTwo { | |
int calculate(vector <int> seq) { | |
int i, j, ans = 0, N = seq.size(); | |
for (i = 0; i < N; i++) { | |
j = i + 1; | |
priority_queue<int> q; q.push(seq[i]); | |
while (j < N && seq[j] > q.top()) { | |
q.push(seq[j]); j += 1; | |
} |
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
class MergeSort(object): | |
def __init__(self): | |
pass | |
def merge(self, left, right): | |
ans = [] | |
while left and right: | |
if left[0] < right[0]: | |
ans.append(left.pop(0)) | |
else: |
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
class LittleElephantAndBallsAgain { | |
public: | |
int getNumber(string); | |
}; | |
set<string> memo; | |
map<string, int> dp; | |
int func(string s) { | |
if (memo.count(s)) { |
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
class LittleElephantAndIntervalsDiv2 { | |
public: | |
int getNumber(int, vector <int>, vector <int>); | |
}; | |
int LittleElephantAndIntervalsDiv2::getNumber(int M, vector <int> L, vector <int> R) { | |
//0 - W, 1 - B | |
vector<int> base(M, 0); | |
queue<pair<vector<int>, int> > q; |
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 <stdio.h> | |
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <stack> | |
#include <queue> | |
#include <math.h> | |
#include <string.h> | |
#define ll long long | |
#define MAXN 100002 |
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 <bits/stdc++.h> | |
using namespace std; | |
typedef long long Int; | |
typedef unsigned uint; | |
class PackingBallsDiv2 { | |
public: |
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 <bits/stdc++.h> | |
template<typename T> T gcd(T a, T b) { | |
if(!b) return a; | |
return gcd(b, a % b); | |
} | |
template<typename T> T lcm(T a, T b) { | |
return a * b / gcd(a, b); | |
} |
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 <bits/stdc++.h> | |
template<typename T> T gcd(T a, T b) { | |
if(!b) return a; | |
return gcd(b, a % b); | |
} | |
template<typename T> T lcm(T a, T b) { | |
return a * b / gcd(a, b); | |
} |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <limits.h> | |
#define MAXL 15 | |
#define MAX_VALUE 10; | |
int* generate(void) { | |
int i; |