|
|
|
|
|
|
|
o******e 发帖数: 74 | 8 对于5个的情形,可以分成2和3来解决。 对于每一个特定的target, 3个元素的找法可
以O(n^2)得到。(通过先对原来的数组排序,再利用 三个指针)
而对于两个元素的和,可以用 O(n^2)建立hashtable, 依次exhaust里面所有的元素ele
, 在3里面找对用的 target = 0 - ele
总时间是O(n^4) |
|
a*******y 发帖数: 1040 | 9 现场写一个吧:
void Subset(int A[],int n)
{
int number = 1<
for (int i = 0;i < number; i++)
{
int temp = i;
int* ele = A;
cout << "{"
while (temp > 0)
{
if (temp&0x01)
count <<*A;
temp >>=1;
++ele;
}
cout <<"} "
}
} |
|
l*****a 发帖数: 14598 | 10 问别人好歹拿点readable的code吧?
what does below 2 statements mean?
ele = arr[i] - k;
if(*front *rear == ele) |
|
f**********t 发帖数: 1001 | 11 class Component {
public:
virtual char next() = 0;
virtual bool hasNext() = 0;
virtual void traverse() = 0;
};
class Leaf : public Component {
char val;
bool _hasNext;
public:
Leaf(char v) : val(v), _hasNext(true) { }
char next() {
_hasNext = false;
return val;
}
bool hasNext() {
return _hasNext;
}
void traverse() {
cout << val << ' ';
}
};
class Composite : public Component {
vector children;
size_t _idx = 0;
void goNext() {
while (_... 阅读全帖 |
|
M*****M 发帖数: 20 | 12 来自主题: JobHunting版 - 一道面试题 类似找最大BST subtree, bottom up.
bool findsubtree(TreeNode *node, unordered_set &set, vector
&vec) {
if(not node) {
return true;
}
unordered_set leftset;
unordered_set rightset;
bool left = findsubtree(node->left, leftset, vec);
bool right = findsubtree(node->right, rightset, vec);
if(left&&right) {
//leftset and rightset overlap
for(auto ele:leftset) {
if(rightset.find(ele)!=rightset.end()) {
... 阅读全帖 |
|
g****9 发帖数: 163 | 13 My code also complains memory limit exceed. Any suggestions why?
LinkedList stack = new LinkedList();
LinkedList ministack = new LinkedList();
public void push(int x) {
stack.add(x);
if (ministack.isEmpty() || ministack.getLast() >= x) {
ministack.add(x);
}
}
public void pop() {
if (stack.isEmpty()) {
return;
}
int ele = stack.removeLast();
if (!ministack... 阅读全帖 |
|
r*g 发帖数: 186 | 14
yes you are right,
I tried your idea and it's much faster than before.
int calcHash(std::vector &v)
{
int res = 0;
for(auto ele: v){
res = res * 2 + ele;
}
return res;
}
bool canIWin(int, int sum, std::vector &v, int obj,
std::unordered_map &cache)
{
int key = calcHash(v);
if(cache.find(key) != cache.end()){
return cache[key];
}
... 阅读全帖 |
|
r*****y 发帖数: 3406 | 15 normally you pay ele every 3 month. what else did you do?
also, $1500 even for 3 month is unbelievable, you should really argue this
with your landlord, ask him to talk to ele company.
my bills last 3 month for 3 people is around $300 only. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
k*******n 发帖数: 2399 | 41 In the future, historians may likely mark the 2010 midterm elections as the
end of the California era and the beginning of the Texas one. In one stunni
ng stroke, amid a national conservative tide, California voters essentially
ratified a political and regulatory regime that has left much of the state u
nemployed and many others looking for the exits.
California has drifted far away from the place that John Gunther described i
n 1946 as "the most spectacular and most diversified American state .... 阅读全帖 |
|
|
|
|
g********0 发帖数: 15010 | 45 The elementary schools (Fields Rd. and Brown Station schools) of the Orchard
Pond and Government are very bad.
Brighton Village goes to Diamond Ele. school, which is much better than
above two ele. schools.
The two middle schools for the three apartments are at the same level. All
three apartments go to the same high school. |
|
g********0 发帖数: 15010 | 46 Yes, It is cheaper in east side of I270 than in west side. There are several
apartments along MD 355 which is not far away from NIST.As you have school
kid, I do not recommend you live there. There are many Lao Mo and Lao Hei
there. So the housing is cheaper. Generally speaking, west side of I270 is
better than east side of I270. west side of MD 355 is better than the east
side of MD 355.
I recommend Bright Village (as I know, the only apartment goes to Diamond ele.) to you as the elementary sc... 阅读全帖 |
|
j*****7 发帖数: 318 | 47 真详细。
非常感谢!
several
school
ele.) to you as the elementary school (Diamond ele.
afford |
|
c*h 发帖数: 33018 | 48 发信人: george9900 (小小虎), 信区: WashingtonDC
标 题: Re: 借人气问下NIST附近租房
发信站: BBS 未名空间站 (Sun Apr 8 22:52:11 2012, 美东)
Bright Village
Yes, It is cheaper in east side of I270 than in west side. There are several
apartments along MD 355 which is not far away from NIST.As you have school
kid, I do not recommend you live there. There are many Lao Mo and Lao Hei
there. So the housing is cheaper. Generally speaking, west side of I270 is
better than east side of I270. west side of MD 355 is better than the eas... 阅读全帖 |
|