楼主: yakhe
跳转到指定楼层
上一主题 下一主题
收起左侧

Linkedin 新鲜onsite

🔗
 楼主| yakhe 2016-3-14 12:07:18 | 只看该作者
全局:
guixi107 发表于 2016-3-14 11:29
pat pat

lz 设计的问题可以提示些不?

那我乱讲讲挂后自己的一些想法,你也就乱听听

先按要求做一些math,算一下数据量,流量,需要的机器数目之类的

感觉此类应用应该是用关系型数据库,data可以自己试着设计一下,API可以这些:query(user, day), insert(user, event), delete(user, event)
scale out的话,因为用户间关联较稀少,所以可以按照用户来shard到不同机器

短时间内notify大量的用户比较麻烦,没想好
回复

使用道具 举报

🔗
guixi107 2016-3-14 12:32:36 | 只看该作者
全局:
yakhe 发表于 2016-3-14 12:07
那我乱讲讲挂后自己的一些想法,你也就乱听听

先按要求做一些math,算一下数据量,流量,需要的机器数 ...

谢谢, 谢谢lz

notify大量用户是什么feature? 是说时间到了, 要在网页上弹出来alert吗?
有考虑recursive event吗, 还是都是一次性的events
回复

使用道具 举报

🔗
duduhaha 2016-3-14 15:42:07 | 只看该作者
全局:
yakhe 发表于 2016-3-14 12:07
那我乱讲讲挂后自己的一些想法,你也就乱听听

先按要求做一些math,算一下数据量,流量,需要的机器数 ...

这题面试官确实是主要考mysql然后加个memcache的。我当时面的说用couchbase,面试官感觉也不是在一个频道上。。
回复

使用道具 举报

🔗
jz33089 2016-6-16 07:56:21 | 只看该作者
全局:
yakhe 发表于 2016-3-1 10:37
差不多,就是从leaf开始是0深度,往上,取左右深度大者加一

Can you post codes. 谢谢
回复

使用道具 举报

🔗
laonong15 2016-6-16 08:42:15 | 只看该作者
全局:
my 1 cent :

public   void takeOffLeaves(TreeNode root) {
      if(root == null) {
            return;        
       }

        Stack<Integer> leafStack = new Stack<>();
        

}
回复

使用道具 举报

🔗
laonong15 2016-6-16 08:47:34 | 只看该作者
全局:
sorry  it is really difficult to write  code   here

my 1 cent :

public   void takeOffLeaves(TreeNode root) {
      if(root == null) {
            return;        
       }
       //use  stack to store all the  level traversal result
        Stack<Integer> leafStack = new Stack<>();
        Queue<TreeNode> queue = new LinkedList<>();
         queue.offer(root);
        while(!queue.isEmpty()){
           do the  level traversal  and put the  leaves to the stack
           }
         while(!leafstatck.isEmpty()){
            system.out.print(stack.poll());
}
回复

使用道具 举报

🔗
jz33089 2016-6-16 09:26:45 | 只看该作者
全局:
laonong15 发表于 2016-6-16 08:47
sorry  it is really difficult to write  code   here

my 1 cent :

level order traversal might not be right? 两个不同 depth 的leaf 要在同一轮输出
回复

使用道具 举报

🔗
laonong15 2016-6-16 11:31:26 | 只看该作者
全局:
jz33089 发表于 2016-6-16 09:26
level order traversal might not be right? 两个不同 depth 的leaf 要在同一轮输出

so  we can do this

Queue<TreeNode> queue = new LinkedList<>();
queue.offer(root);
while(!queue.isEmpty()){
   int size = queue.size();
   for(int i =0; i < size; i++) {
        TreeNode node = queue.poll();
        if(isLeaf(node)) {
            system.out.print(node.val +" ");
         }
        if(node.left != null) {
             if(isLeaf(node.left)) {
                  System.out.print(node.left);
            } else {
              queue.offer(node.left);
              stack.push(node.left);
          }
       }
// do same thing  for the  node.right
   }


then  popup from  the stack. and  output  like code above
}
回复

使用道具 举报

🔗
laonong15 2016-6-16 12:25:40 | 只看该作者
全局:
sorry  can not  type chinese  here
mess up   "every round" with  "every level"

so  by  every round  it  is straight  forward .

public  void removeLeaveByRound(TreeNode root) {
        while(root != null) {
            root = removeAllLeaves(root);
       }      
}

private TreeNode removeAllLeaves(TreeNode root){
    if (root == null || ( root.left == null && root.right == null ))
             return null;
    root.left = removeLeaves( root.left );
    root.right = removeLeaves(root.right );
    return root;
}
回复

使用道具 举报

🔗
jz33089 2016-6-16 12:35:31 | 只看该作者
全局:
laonong15 发表于 2016-6-16 12:25
sorry  can not  type chinese  here
mess up   "every round" with  "every level"

Can we do it without changing tree itself?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表