s*0
2 楼
Sephora still takes up to 75% off select cosmetics, bath products, and
beauty accessories in its sale section. Shipping adds $5.95, or spend $50 or
more to qualify for free shipping. Of note, you'll have a choice of three
beauty samples for free at checkout. Some best bets:
•Dylan's Candy Lip Salve Stackable Set for $7.50
•Sephora Collection Retractable Foundation Brush #56 for $10
•Urban Decay Eyeshadow Duo (pictured) for $19
•Tarte Lights, Camera, Lashes! Mascara and Rejuvelash Lash Exhilirator
Duo for $19
•Too Faced Tanning Bed in a Tube and Snow Bunny Lip Bronzer for $21.50
link:
http://www.sephora.com/
对这些select items不是很了解,jms自己发掘吧!
beauty accessories in its sale section. Shipping adds $5.95, or spend $50 or
more to qualify for free shipping. Of note, you'll have a choice of three
beauty samples for free at checkout. Some best bets:
•Dylan's Candy Lip Salve Stackable Set for $7.50
•Sephora Collection Retractable Foundation Brush #56 for $10
•Urban Decay Eyeshadow Duo (pictured) for $19
•Tarte Lights, Camera, Lashes! Mascara and Rejuvelash Lash Exhilirator
Duo for $19
•Too Faced Tanning Bed in a Tube and Snow Bunny Lip Bronzer for $21.50
link:
http://www.sephora.com/
对这些select items不是很了解,jms自己发掘吧!
C*5
3 楼
Help :)
Is it too easy?
Is it too easy?
m*g
4 楼
是不是和leetcode的tree deserialization 一样, 不过return判断条件是node level
not equal to current level. Current level 是recursion function 的输入参数
。
not equal to current level. Current level 是recursion function 的输入参数
。
y*x
5 楼
似乎可以用stack?
如果当前读到的level等于前一个节点的level+1,则当前节点是前一个节点的左节点。
否则,从栈中重新获取前一个节点,直到满足判断条件,则当前节点是前一个节点的右
节点。最后把当前节点压栈。循环直到栈为空,构建完成。
主要流程的伪代码大致如下(没考虑null等细节)
stack.push(root);
while(!stack.isEmpty()){
read value and level from input.
TreeNode cur = new TreeNode(value,level);
if(cur.level=pre.level+1){
pre.left=cur;
}else{
while(cur.level!=pre.level+1){
pre = stack.pop();
}
pre.right = cur;
}
pre = cur;
stack.push(cur);
}
如果当前读到的level等于前一个节点的level+1,则当前节点是前一个节点的左节点。
否则,从栈中重新获取前一个节点,直到满足判断条件,则当前节点是前一个节点的右
节点。最后把当前节点压栈。循环直到栈为空,构建完成。
主要流程的伪代码大致如下(没考虑null等细节)
stack.push(root);
while(!stack.isEmpty()){
read value and level from input.
TreeNode cur = new TreeNode(value,level);
if(cur.level=pre.level+1){
pre.left=cur;
}else{
while(cur.level!=pre.level+1){
pre = stack.pop();
}
pre.right = cur;
}
pre = cur;
stack.push(cur);
}
A*o
7 楼
贴个递归的完整代码,抛砖引玉了
#include
#include
#include
#include
using namespace std;
// Interview question: Rebuild a tree with DFS output with level
// A, 0, B, 1, C, 2, D, 2
struct TreeNode {
string id;
TreeNode(string a) {
id = a;
}
vector children;
};
void rebuildImpl(istringstream & iss, TreeNode *&father, string id, int
level) {
TreeNode *p = new TreeNode(id);
if (!father) {
father = p;
}
else {
father->children.push_back(p);
}
string nextId;
int nextLevel;
if (iss >> nextId >> nextLevel) {
if (nextLevel == level) {
rebuildImpl(iss, father, nextId, nextLevel);
}
else { // l == level+1
rebuildImpl(iss, p, nextId, nextLevel);
}
}
}
TreeNode* rebuild(const string &seq) {
istringstream iss(seq);
string id;
int level;
TreeNode *root = NULL;
if (iss >> id >> level) {
rebuildImpl(iss, root, id, level);
}
return root;
}
void dfs(TreeNode *node, int level) {
if (!node) {
return;
}
cout << node->id << " " << level << " ";
for (int i = 0; i < node->children.size(); i++) {
dfs(node->children[i], level+1);
}
}
int main() {
string trail = "A 0 B 1 C 2 D 2";
TreeNode *root = rebuild(trail);
dfs(root, 0); // should print same trail
cout << endl;
return 0;
}
#include
#include
#include
#include
using namespace std;
// Interview question: Rebuild a tree with DFS output with level
// A, 0, B, 1, C, 2, D, 2
struct TreeNode {
string id;
TreeNode(string a) {
id = a;
}
vector
};
void rebuildImpl(istringstream & iss, TreeNode *&father, string id, int
level) {
TreeNode *p = new TreeNode(id);
if (!father) {
father = p;
}
else {
father->children.push_back(p);
}
string nextId;
int nextLevel;
if (iss >> nextId >> nextLevel) {
if (nextLevel == level) {
rebuildImpl(iss, father, nextId, nextLevel);
}
else { // l == level+1
rebuildImpl(iss, p, nextId, nextLevel);
}
}
}
TreeNode* rebuild(const string &seq) {
istringstream iss(seq);
string id;
int level;
TreeNode *root = NULL;
if (iss >> id >> level) {
rebuildImpl(iss, root, id, level);
}
return root;
}
void dfs(TreeNode *node, int level) {
if (!node) {
return;
}
cout << node->id << " " << level << " ";
for (int i = 0; i < node->children.size(); i++) {
dfs(node->children[i], level+1);
}
}
int main() {
string trail = "A 0 B 1 C 2 D 2";
TreeNode *root = rebuild(trail);
dfs(root, 0); // should print same trail
cout << endl;
return 0;
}
p*2
10 楼
rebuild = (arr)->
stack = []
while arr.length > 0
[ch, lv] = arr
if lv is stack.length
node = {val: ch, children:[]}
stack[-1..][0]?.children.push(node)
stack.push(node)
arr = arr[2..]
else
stack.pop()
stack[0]
stack = []
while arr.length > 0
[ch, lv] = arr
if lv is stack.length
node = {val: ch, children:[]}
stack[-1..][0]?.children.push(node)
stack.push(node)
arr = arr[2..]
else
stack.pop()
stack[0]
相关阅读
Coach 100 off 300没有人讨论【敏敏格格】还有【绿芜】啊请问哪里买手表?这个算好deal吗 guess 过膝皮靴 51刀(含税免运费)Coach Factory -- The Official Online Sale: up to 70% off弱弱的问retinol可以用在眼部不?13件行头的31种搭配世界恐怖童话故事UGG哪里有outlet转让:Salvatore Ferragmamo ShoesAE, Aerie & 77kidsA&F 25% off code什么是eye primer??Amex 开卡送1000刀 Gold Premier Card Match 75K points bonusStella mid-heel bootie ( what do you think #1, #2)觉得自己跳deal太疯狂了,刚买了两件婚纱……求推荐一款不搓泥的保湿面霜Tiffany最近出的几个宝葫芦想买双银色的鞋,请推荐[deal] AIX 50 off 150 purchase