Redian新闻
>
visa gc 不能load进 blue bird了
avatar
visa gc 不能load进 blue bird了# Money - 海外理财
i*e
1
这道题大家做做看:
给定 n,生成所有不重复的 BSTs,里面节点所包含的值必须个别为 1 到 n。
input 是 n,output 是 list of
avatar
l*r
2
我online load两次后, 被拒。刚打电话问bluebird,被告知所有gift card都不能
load,即使去walmart也不行。有相同经历的童鞋吗?
avatar
f*e
3
递归看行不行。

【在 i**********e 的大作中提到】
: 这道题大家做做看:
: 给定 n,生成所有不重复的 BSTs,里面节点所包含的值必须个别为 1 到 n。
: input 是 n,output 是 list of

avatar
a*x
4
online原来还可以load啊

【在 l****r 的大作中提到】
: 我online load两次后, 被拒。刚打电话问bluebird,被告知所有gift card都不能
: load,即使去walmart也不行。有相同经历的童鞋吗?

avatar
w*x
5

这题就是for里递归吧

【在 i**********e 的大作中提到】
: 这道题大家做做看:
: 给定 n,生成所有不重复的 BSTs,里面节点所包含的值必须个别为 1 到 n。
: input 是 n,output 是 list of

avatar
n*s
6
去walmart能load是因为当作debit用的?要不输啥子pin?

【在 l****r 的大作中提到】
: 我online load两次后, 被拒。刚打电话问bluebird,被告知所有gift card都不能
: load,即使去walmart也不行。有相同经历的童鞋吗?

avatar
l*a
7


【在 w****x 的大作中提到】
:
: 这题就是for里递归吧

avatar
s*t
8
bb is not for u
quit it for your own good

【在 l****r 的大作中提到】
: 我online load两次后, 被拒。刚打电话问bluebird,被告知所有gift card都不能
: load,即使去walmart也不行。有相同经历的童鞋吗?

avatar
v*d
9
试着做了一下
Node* findAllBSTs(int beginIndex, int endIndex, Node* origHead, Node*
curParent) {
if ( endIndex - beginIndex < 0 )
return NULL;
else if ( endIndex - beginIndex == 0 ) {
Node* newNode = new Node(values[beginIndex], NULL, NULL);
return newNode;
}
else {
for ( int i = beginIndex; i <= endIndex; i++ ) {
curParent->value = values[i];

if ( beginIndex <= i-1 )
curParent->leftChild = new Node(0, NULL, NULL);
else
curParent->leftChild = NULL;

if ( i+1 <= endIndex )
curParent->rightChild = new Node(0, NULL, NULL);
else
curParent->rightChild = NULL;

curParent->leftChild = findAllBSTs(beginIndex, i-1, origHead,
curParent->leftChild);
curParent->rightChild = findAllBSTs(i+1, endIndex, origHead,
curParent->rightChild);

if ( beginIndex == i-1 && i+1 == endIndex ) {
//deep copy "orighead" to a global vector object
}
}
}
return NULL;
}
avatar
a*9
10
u need to go to Walmart to load visa gc. buy vanilla for online loading
avatar
i*e
11
感觉真心不好写啊这题!!! 写了个有Bug的程序(晕死):
struct node{
int value;
node* lchild;
node* rchild;
node(int v):value(v), lchild(0), rchild(0){};
};
vector help(int start, int end)
{
vector result;
if(start > end) return result;
if(start == end)
{
result.push_back(new node(start));
return result;
}
for(int i = start; i <= end; i++)
{
vector left = help(start, i-1);
vector right = help(i+1, end);
node* r = new node(i);
if(left.empty())
{
for(int j = 0; j < right.size(); j++)
{
r->rchild = right[j];
result.push_back(r);
}
}
else if(right.empty())
{
for(int j = 0; j < left.size(); j++)
{
r->lchild = left[j];
result.push_back(r);
}
}
else
{
for(int j = 0; j < left.size(); j++)
{
r->lchild = left[j];
for(int k = 0; k < right.size(); k++)
{
r->rchild = right[k];
result.push_back(r);
}
}
}
}
return result;
}
vector buildBSTs(int n)
{
return help(1,n);
}
avatar
a*o
12
以后这类的东西不要问客服免得被砍,去walmart可以load
avatar
i*e
13
感觉思路是对的, 但是结果却有问题, 这个题目没有想象中那么简单..求大牛指点!
avatar
s*t
14
plz change your image icon, seriously

【在 a*******o 的大作中提到】
: 以后这类的东西不要问客服免得被砍,去walmart可以load
avatar
i*e
15
感觉不对啊!! 你的应该比实际的解少的多?

【在 v***d 的大作中提到】
: 试着做了一下
: Node* findAllBSTs(int beginIndex, int endIndex, Node* origHead, Node*
: curParent) {
: if ( endIndex - beginIndex < 0 )
: return NULL;
: else if ( endIndex - beginIndex == 0 ) {
: Node* newNode = new Node(values[beginIndex], NULL, NULL);
: return newNode;
: }
: else {

avatar
y*e
16
online从来都不可以load。bluebird会online联系发卡银行验证是不是gift卡。
去walmart offline还可以load,因为这一层验证还不在。现在已经有些walmart的小二
不让刷gift card load了,但是walmart atm还可以刷。
这种事情置顶贴不是说了不要打客服么。不要搞得walmart atm这条路也断了。

【在 l****r 的大作中提到】
: 我online load两次后, 被拒。刚打电话问bluebird,被告知所有gift card都不能
: load,即使去walmart也不行。有相同经历的童鞋吗?

avatar
s*n
17
抛个砖。
n个节点的树和n对valid parentheses是一一对应的。可以每生成一个valid
parentheses string,然后生成一棵BST。
avatar
m*a
18
deal就是被楼主这样的人搞死的

【在 l****r 的大作中提到】
: 我online load两次后, 被拒。刚打电话问bluebird,被告知所有gift card都不能
: load,即使去walmart也不行。有相同经历的童鞋吗?

avatar
h*n
19
2^n-n in total,
take 1~n as inorder traversal,
recursion i as root node, T(i) = T(i-1) + T(n-i) ?

【在 i**********e 的大作中提到】
: 这道题大家做做看:
: 给定 n,生成所有不重复的 BSTs,里面节点所包含的值必须个别为 1 到 n。
: input 是 n,output 是 list of

avatar
n*s
20
是这么回事。缺乏一些常识。

【在 m*****a 的大作中提到】
: deal就是被楼主这样的人搞死的
avatar
t*l
21
that's my first thought, too. simple recursion can do the job.

【在 h*****n 的大作中提到】
: 2^n-n in total,
: take 1~n as inorder traversal,
: recursion i as root node, T(i) = T(i-1) + T(n-i) ?

avatar
y*e
22
严格来说gift卡不能套现。但是walmart atm那边还没加验证,所以能load进bluebird
。明白了? 其他方式不要去尝试也不要问。

【在 l****r 的大作中提到】
: 我online load两次后, 被拒。刚打电话问bluebird,被告知所有gift card都不能
: load,即使去walmart也不行。有相同经历的童鞋吗?

avatar
i*e
23
right. Catalan numbers!!

【在 s*****n 的大作中提到】
: 抛个砖。
: n个节点的树和n对valid parentheses是一一对应的。可以每生成一个valid
: parentheses string,然后生成一棵BST。

avatar
c*s
24
Don't call!
avatar
i*e
25
that's wrong! please google "catalan numbers"

【在 h*****n 的大作中提到】
: 2^n-n in total,
: take 1~n as inorder traversal,
: recursion i as root node, T(i) = T(i-1) + T(n-i) ?

avatar
m*6
26
BB对网上reload一直查得不紧不慢啊,我的paypal debit前两天也被停了
avatar
h*e
27
是的,又想起了趣味数学。

【在 i***e 的大作中提到】
: right. Catalan numbers!!
avatar
h*n
28
I had a typo, the recursion should be multiplications
T(n) = \sum_i=0^(n-1) T(i)*T(n-1-i)
catalan numbers is correct, the recursions shows how "catalan numbers" are
calculated.

【在 i***e 的大作中提到】
: that's wrong! please google "catalan numbers"
avatar
l*7
29

记录结果实在是不容易。我能想到的方法,
得到所有可能的前序遍历,那么生成树就可以根据前序遍历序列(以及中序遍历)
一棵棵建立了。递归是很难得到所有的前序遍历了,那就迭代吧。
节点 k 作为 根节点, 1...k-1为左子树 (可能为空), k + 1 ... n为右子树(可能为
空)
h(n) = h(0)*h(n-1) + h(1)*h(n-2) + ... + h(n-1)*h(0)
恩,应该就是卡塔兰数了。
构建树:
依次建立和记录
h(0) -- 空树
h(1) -- 一个点的树
h(2) -- 二个点的树
。。。
h(n-1)
序列h(n) 就可以通过 h(0) h(1)...h(n-1) 来建立了
这里要小心的是, 比如 考虑 h(k) * h(n - 1 - k)
连接序列 h(k) 这个集合和 h(n - 1 - k)时, 序列h(n - 1 - k)中的值都要加上一个
笃定的值, i.e., k + 1
这里的序列链接(* 运算)相当于笛卡尔积。
有错请指出!

【在 i**********e 的大作中提到】
: 这道题大家做做看:
: 给定 n,生成所有不重复的 BSTs,里面节点所包含的值必须个别为 1 到 n。
: input 是 n,output 是 list of

avatar
j*o
30
求TEST...
list unique(int start, int end){
list res;
if(start > end) return res;
list leftChild,rightChild;
list::iterator iter1,iter2;
for(int i=start; i<=end; i++){
leftChild=unique(start,i-1);
rightChild=unique(i+1,end);
if(leftChild.empty()) leftChild.push_back(NULL);
if(rightChild.empty()) rightChild.push_back(NULL);
for(iter1=leftChild.begin(); iter1!=leftChild.end(); iter1++)
for(iter2=rightChild.begin(); iter2!=rightChild.end(); iter2++){
Node *root=new Node(i);
root->left=*iter1;
root->right=*iter2;
res.push_back(root);
}
}
return res;
}
list uniqueBST(int n){
return unique(1,n);
}

【在 i**********e 的大作中提到】
: 这道题大家做做看:
: 给定 n,生成所有不重复的 BSTs,里面节点所包含的值必须个别为 1 到 n。
: input 是 n,output 是 list of

avatar
c*e
31
http://cslibrary.stanford.edu/110/BinaryTrees.html#s2
question 12.

【在 i**********e 的大作中提到】
: 这道题大家做做看:
: 给定 n,生成所有不重复的 BSTs,里面节点所包含的值必须个别为 1 到 n。
: input 是 n,output 是 list of

avatar
i*e
32
已经收录了这题在 OJ "Unique Binary Search Trees II",大家有兴趣可以测一下代
码.
avatar
i*e
33
顶大牛的做的网站, 非常棒啊!! 只是发现已经很久没有加新题目了。。

【在 i**********e 的大作中提到】
: 已经收录了这题在 OJ "Unique Binary Search Trees II",大家有兴趣可以测一下代
: 码.

avatar
i*e
34
要加很多二叉树的题目了,敬请期待!

【在 i***e 的大作中提到】
: 顶大牛的做的网站, 非常棒啊!! 只是发现已经很久没有加新题目了。。
avatar
w*x
35

别加了, 够啦, 再加做不完又有负罪感了

【在 i**********e 的大作中提到】
: 要加很多二叉树的题目了,敬请期待!
avatar
i*e
36
不错!就是这样的简洁代码 :)
其实你可以删除以下这两行:
if(leftChild.empty()) leftChild.push_back(NULL);
if(rightChild.empty()) rightChild.push_back(NULL);
然后小心 handle start > end 的特殊状况 (n == 0 空树的情况? ):
if(start > end) {
res.push_back(NULL);
return res;
}

【在 j*****o 的大作中提到】
: 求TEST...
: list unique(int start, int end){
: list res;
: if(start > end) return res;
: list leftChild,rightChild;
: list::iterator iter1,iter2;
: for(int i=start; i<=end; i++){
: leftChild=unique(start,i-1);
: rightChild=unique(i+1,end);
: if(leftChild.empty()) leftChild.push_back(NULL);

avatar
h*e
37
不加的话你能做满800题吗?

【在 w****x 的大作中提到】
:
: 别加了, 够啦, 再加做不完又有负罪感了

avatar
e*s
38
泪牛满面,这要在interview问我,我就只能去死了

【在 j*****o 的大作中提到】
: 求TEST...
: list unique(int start, int end){
: list res;
: if(start > end) return res;
: list leftChild,rightChild;
: list::iterator iter1,iter2;
: for(int i=start; i<=end; i++){
: leftChild=unique(start,i-1);
: rightChild=unique(i+1,end);
: if(leftChild.empty()) leftChild.push_back(NULL);

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。