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

Google电面跪经

🔗
UC小王子 2018-11-8 02:19:38 | 只看该作者
全局:
bc2615 发表于 2018-11-8 00:03
请问具体题目叫什么?

可能是蠡口司二奇

评分

参与人数 1大米 +5 收起 理由
bc2615 + 5 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
foryousee 2018-11-8 02:43:28 | 只看该作者
全局:
sherlockzzq 发表于 2018-11-8 02:19
可能是蠡口司二奇

对,就是这道题
回复

使用道具 举报

🔗
foryousee 2018-11-8 02:44:25 | 只看该作者
全局:
ewyy 发表于 2018-11-7 18:40
请问有蠡口题号吗

肆迩鳍,字数
回复

使用道具 举报

🔗
foryousee 2018-11-8 02:44:31 | 只看该作者
全局:
tjuwdz95 发表于 2018-11-7 22:13
同求题号,查标题没有查到

肆迩鳍,字数

评分

参与人数 1大米 +5 收起 理由
bc2615 + 5 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
coolandrew 2018-11-8 02:49:37 | 只看该作者
全局:
ewyy 发表于 2018-11-7 18:40
请问有蠡口题号吗

没看到楼主的题目,但听这意思像是利口四而起
回复

使用道具 举报

🔗
coolandrew 2018-11-8 02:50:23 | 只看该作者
全局:
bc2615 发表于 2018-11-8 00:03
请问具体题目叫什么?

没看到楼主的题目,但听这意思像是利口四而起的变种?
回复

使用道具 举报

🔗
coolandrew 2018-11-8 02:50:50 | 只看该作者
全局:
tjuwdz95 发表于 2018-11-7 22:13
同求题号,查标题没有查到

没看到楼主的题目,但感觉像是利口四而起?
回复

使用道具 举报

🔗
大木虫 2018-11-8 09:33:52 | 只看该作者
全局:
里口思儿其的代码
  1. /*
  2. // Definition for a QuadTree node.
  3. class Node {
  4. public:
  5.     bool val;
  6.     bool isLeaf;
  7.     Node* topLeft;
  8.     Node* topRight;
  9.     Node* bottomLeft;
  10.     Node* bottomRight;

  11.     Node() {}

  12.     Node(bool _val, bool _isLeaf, Node* _topLeft, Node* _topRight, Node* _bottomLeft, Node* _bottomRight) {
  13.         val = _val;
  14.         isLeaf = _isLeaf;
  15.         topLeft = _topLeft;
  16.         topRight = _topRight;
  17.         bottomLeft = _bottomLeft;
  18.         bottomRight = _bottomRight;
  19.     }
  20. };
  21. */
  22. class Solution {
  23. public:
  24.     Node* construct(vector<vector<int>>& grid) {
  25.         return ConstructRec(grid, {0, 0}, {grid.size()-1, grid[0].size()-1} );
  26.     }
  27.    
  28.     Node* ConstructRec(const vector<vector<int> > & grid, const pair<int, int>& topLeft, const pair<int, int>& bottomRight){
  29.         Node* node = new Node();
  30.         node->topLeft = NULL;
  31.         node->topRight = NULL;
  32.         node->bottomLeft = NULL;
  33.         node->bottomRight = NULL;
  34.         node->val = grid[topLeft.first][topLeft.second];
  35.         if(!IsUniversal(grid, topLeft, bottomRight)){
  36.             node->isLeaf = false;
  37.             pair<int, int> center = {(topLeft.first + bottomRight.first) / 2, (topLeft.second + bottomRight.second) / 2};
  38.             node->topLeft = ConstructRec(grid, topLeft, center);
  39.             node->topRight = ConstructRec(grid, {topLeft.first, center.second+1}, {center.first, bottomRight.second});
  40.             node->bottomLeft = ConstructRec(grid, {center.first+1, topLeft.second}, {bottomRight.first, center.second});
  41.             node->bottomRight = ConstructRec(grid, {center.first+1, center.second+1}, bottomRight);
  42.         }else node->isLeaf = true;        
  43.         
  44.         return node;
  45.         
  46.     }
  47.    
  48.     bool IsUniversal(const vector<vector<int> > & grid,
  49.                      const pair<int, int>& topLeft, const pair<int, int>& bottomRight){
  50.         int val = grid[topLeft.first][topLeft.second];
  51.         for(int i = topLeft.first; i <= bottomRight.first; ++i){
  52.             for(int j = topLeft.second; j <= bottomRight.second; ++j){
  53.                 if(val != grid[i][j]){
  54.                     return false;
  55.                 }
  56.             }
  57.         }
  58.         return true;
  59.     }
  60. };
复制代码
回复

使用道具 举报

🔗
wulaoshi250 2018-11-8 13:15:52 | 只看该作者
全局:
大木虫 发表于 2018-11-8 09:33
里口思儿其的代码
[mw_shl_code=cpp,true]/*
// Definition for a QuadTree node.

请问对这个题有啥思路么?
回复

使用道具 举报

🔗
wulaoshi250 2018-11-8 13:16:26 | 只看该作者
全局:

请问对这个题有啥思路么?
回复

使用道具 举报

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

本版积分规则

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