注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
本帖最后由 zenlotus 于 2019-10-10 04:30 编辑
Zoox (无人车/智能车) 软件工程师电面
由于该公司核心团队主要是用C++,所以选择了C++面试
第一面并不太理想,反馈是说C++的知识性的问题回答得还可以,就是编程题不太好,该题主要是靠OO设计、多态性等
“设计一个批处理图像的简单系统.
输入是peline? ”
- // Mock image manipulation library.
- // Do not modify.
- namespace ImgLib {
- void convertToGrayScale (Image & img) {
- cout << img.name() << ": Converting to gray scale" << endl;
- }
- void blur (Image & img, float factor) {
- cout << img.name() << ": Blurring with factor " << factor << endl;
- }
- void resize (Image & img, int x, int y) {
- cout << img.name() << ": Resizing img with x = " << x << " and y = " << y << endl;
- }
- void blend (Image & img, const Image& other) {
- cout << img.name() << ": Blending with " << other.name() << endl;
- }
- // ******************************************************************
- // * *
- // * NOTE: There are at least 1000 additional functions. *
- // * The rest have been omitted due to the scope of the exercise. *
- // * *
- // ******************************************************************
- } // namespace ImgLib
复制代码
后来领会到主要是要做成抽象类,pure virtual function等
大概是这个样子
- class AbstractOperation {
- public:
- virtual ~AbstractOperation() = default;
- virtual void execute(Image& image) = 0;
- };
- class ConvertToGrayScaleOperation : AbstractOperation {
- public:
- ConvertToGrayScaleOperation();
- Execute(Image& image) {
- ImgLib::ConvertToGrayScale(image);
- }
- };
- class BlurOperation : AbstractOperation {
- public:
- BlurOperation(double factor) : factor_(factor);
- Execute(Image& image) {
- ImgLib::Blur(image, factor_);
- }
- private:
- double factor_;
- }
-
- class ResizeOperation : AbstractOperation {
- public:
- ResizeOperation(int width, int height) : width_(width), height_(height);
- Execute(Image& image) {
- ImgLib::Resize(image, width_, height_);
- }
- private:
- int width_;
- int height_;
- }
复制代码
|