📜  彭博专访 |第一套(电话采访)

📅  最后修改于: 2022-05-13 01:58:41.884000             🧑  作者: Mango

彭博专访 |第一套(电话采访)

单击此处查看视频会议的文档。

在继续阅读本文之前,请确保您阅读了一些关于Bloomberg的信息,最重要的是它在伦敦的研发中心,您将有足够的时间告诉面试官您对Bloomberg的了解,面试官说他工作的时间更多在彭博社工作了 11 年以上,所以如果您只是编造一些答案,那就不好了,只需阅读一下即可。

面试,伊恩,提前一个小时开始,面试官给了我一些时间准备我的机器,如果发生在你身上,不要惊慌,当然你可以告诉他你更喜欢准时面试。

面试官首先介绍了自己,以及他在彭博社一直使用的技术。
接下来,我被要求自我介绍,我们讨论了我的简历、我的教育和项目。

面试官然后跳到技术问题,通过粘贴代码主体,以填写功能:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
  
//1234
//1,234
  
// 104450 -> 104,450
// 123123123 -> 123,123,123
  
// 1000000 -> 10,00,000
// 00010100
  
string formatNum(int num) {
  
}
  
int main() {
    string res;
    int _num;
    cin >> _num;
      
    res = formatNum(_num);
    cout << res;
      
    return 0;
}

//这是Bloomberg第一次电话采访的一部分

这个问题很简单,我被要求实现一个给定整数 num 的函数,它返回数字的字符串表示形式,逗号分隔。
即 f(1234) = “1,234”

我的实现如下:

string formatNum(int num) {
  
    int total_processed = 0;
    string ret = "";
  
    while (num > 0){
        if (total_processed != 0 && total_processed %3 == 0)
            ret += ",";
        ret += (char) (num %10 + '0');
        total_processed ++;
        num /= 10;
    }
    reverse (ret.begin(), ret.end());
  
    return ret;
}

面试官接着问该函数应该支持不同的逗号样式,即美国与印度风格
//印度 1000000 -> 10,00,000
//美国 1000000 -> 1,000,000

我建议应该将某种样式传递给函数,或者作为整数掩码或整数向量,表示需要逗号的位置。
他问是否只能将字符串缩写而不是向量发送给函数,所以我建议使用映射,它为每个样式代码存储对应的整数向量。

我的实现如下:

//EN style = {3, 6, 9, 12, 15}
//IN style = {3, 5, 7, 9, 11, 13}
  
//map  > style_map
  
string formatNum(int num, string rec_style) {
  
    int total_processed = 0;
    string ret = "";
    vector  style = style_map[rec_style];
    int n = style.size();
    n--;
  
    while (num > 0){
        //if (total_processed != 0 && total_processed %3 == 0)
        if (total_processed == style[n]){ 
            ret += ",";
            n--;
        }
        ret += (char) (num %10 + '0');
        total_processed ++;
        num /= 10;
    }
  
    reverse (ret.begin(), ret.end());
  
    return ret;
}

然后我们转到另一个问题,即关注 OOP。
面试官问我要创建什么类以使这段代码更有用。
我建议我应该为表示的整数创建一个类,来封装它的数值、它的字符串值、它的样式以及与之关联的函数。

代码如下:

class something{
    string num, rec_style;
    something(int n, string style);
    change_style(string new_style);
    bool operator < (something e) const{        
    }
}

然后面试官让我详细说明继承原则。
我使用车辆(汽车,货车,卡车,公共汽车......等)的例子来说明它
然后我们讨论了我的设计偏好,关于类继承和多态性,以及做什么:更多的继承与更多的编码。
我的回答涵盖了代码维护和可重用性。

然后我有机会向面试官询问我对公司和他在彭博工作的任何看法。

结果:我转而与其他面试官进行视频会议。

总结:面试很简单,你只要保持冷静,尽量不夸张地给出答案,祝你好运!

您可以在此处查看视频会议的文档。