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]
相关阅读
两双鞋求建议我也来说说脱发American Eagle 20% off everything with free shipping thru Sunday有要jurlique25off50code的不?奔了,我钟爱的长裙~美女走光的时候,我还挺机灵的我怒了!!!Philosophy 20% OFFClinique 和 Origins DEAL中国女人40也就才这样吧[Deal] Banana Republic addtional 40% off请教关于maxi dress的洗涤问题。。人在台湾,大家有什么推荐买的化妆/护肤品吗奔——脸晒伤了,只能奔自己捣鼓的发型,多图!这个小伙帅不?版版在不在呢?昨天入了个机车皮请问那种夹的耳环在哪家店有卖?saks最近会有打折么?free full size origins cleanser