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

fb实习挂经

🔗
hanxx862 2020-10-2 05:24:42 | 只看该作者
全局:
楼主选的location 在纽约?
回复

使用道具 举报

🔗
huisuetkwan 2020-10-3 11:11:14 | 只看该作者
全局:
mhwylxy 发表于 2020-10-1 12:32
我也遇到了最后一题,不过45分钟只做了这一题。尤其是后面手跑case用了接近十分钟吧。

想纠正一下,走迷 ...

求问是LC63这样的吗~
回复

使用道具 举报

🔗
mhwylxy 2020-10-4 23:50:44 | 只看该作者
全局:
huisuetkwan 发表于 2020-10-3 11:11
求问是LC63这样的吗~

@楼主
回复

使用道具 举报

全局:
还差2分就可以看题目了,求米🥺🥺

评分

参与人数 2大米 +2 收起 理由
meimingzi2020 + 1 赞一个
littledonkey15 + 1 赞一个

查看全部评分

回复

使用道具 举报

🔗
muxiazhixing 2020-10-6 22:30:53 | 只看该作者
全局:
doubly linkedlist sort那题是不是可以用merge sort那种divide and conquer的办法
回复

使用道具 举报

🔗
过客824 2020-10-9 09:26:00 | 只看该作者
全局:
楼主方便提供一下timeline嘛?
回复

使用道具 举报

全局:
本帖最后由 儒雅随和的小川 于 2020-10-12 08:03 编辑

如果要用recursion的话应该需要提取左右两个子树的首位结点然后和root串起来,算法上有点类似lc114的解法,随便写了一个不知道对不对,有问题请大家一起帮忙指出来看看。
def BST_to_DLS(root):                                                                                                                                                                                                                                                                                                                                                                                                                                if not root: return None, None
    node = ListNode(root.val)
    if not root.left and not root.right: return node, node
    left_head, left_tail = BST_to_DLS(root.left)
    right_head, right_tail = BST_to_DLS(root.right)
    if left_tail:
        left_tail.next = node
    node.prev = left_tail
    if right_head:
        right_head.prev = node
    node.next = right_head
    head = left_head if left_head else node
    tail = right_tail if right_tail else node
    return head, tail
return BST_to_DLS(root)[0]



补充内容 (2020-10-13 02:56):
原题应该是LC426
做了一下仅供参考:
https://leetcode.com/problems/co ... -divide-and-conquer
回复

使用道具 举报

🔗
 楼主| Donononon 2020-10-16 02:36:33 | 只看该作者
全局:
muxiazhixing 发表于 2020-10-6 22:30
doubly linkedlist sort那题是不是可以用merge sort那种divide and conquer的办法

求米。。。。。
原题是LC426,
解法应该是:
class Solution {
public:
    Node* head =NULL;
    Node* tray =NULL;
    void helper(Node* root){
        if(root == NULL) return;
        helper(root->left);
        if(tray == NULL){
            head = root;
            tray =root;
        }
        else{
            tray->right = root;
            root->left =tray;
            tray = root;
        }
        helper(root->right);
    }
   
   
    Node* treeToDoublyList(Node* root) {
        if(root ==NULL) return NULL;
        helper(root);
        head->left = tray;
        tray->right = head;
        return head;
    }
};

评分

参与人数 1大米 +2 收起 理由
muxiazhixing + 2 虽然我现在已有offer啦但还是给你加个米

查看全部评分

回复

使用道具 举报

🔗
 楼主| Donononon 2020-10-16 02:37:11 | 只看该作者
全局:

求个米。。。。
原题是LC426,
解法应该是:
class Solution {
public:
    Node* head =NULL;
    Node* tray =NULL;
    void helper(Node* root){
        if(root == NULL) return;
        helper(root->left);
        if(tray == NULL){
            head = root;
            tray =root;
        }
        else{
            tray->right = root;
            root->left =tray;
            tray = root;
        }
        helper(root->right);
    }
   
   
    Node* treeToDoublyList(Node* root) {
        if(root ==NULL) return NULL;
        helper(root);
        head->left = tray;
        tray->right = head;
        return head;
    }
};
回复

使用道具 举报

全局:
niubility
回复

使用道具 举报

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

本版积分规则

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