<
回复: 0
收起左侧

Hopper面经

匿名用户-V8HNW  2022-4-21 11:43:41
本楼:   👍  0
0%
0%
0   👎

2022(4-6月) 码农类General 本科 全职@hopper - 猎头 - 技术电面 视频面试 其他  | 😃 Positive 😐 AverageOther | 在职跳槽
新人求大米。第一次发帖蟹蟹٩('ω')و。

疫情前17/18年的时候就开始用过Hopper的app订机票,用户体验很不错.我是通过猎头联系申请的这个SDE职位. 是HOTEL部门的head count. 永久REMOTE.

第一轮就是和HR聊天. 讨论一下你的背景. 介绍介绍公司的业务. 介绍介绍公司技术层面有很多的FLAG高层的大佬们. 讲了他们有很多Scala的开源大佬等等. 待遇可以媲美FLAG.但是技术要求也相对较高.
第二轮是一个4小时的OA. 按照用户所选择的对话,来打印出和AI的对话。一共7个Test Case。 我一开始写对了1,2,3。但是最终写4的时候3又错了。交的时候就变成1,2,4。 没想到被告知有下一轮电
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
教我一下蟹蟹。)
  1. Ticket{
  2.     String id
  3.     String floor
  4. }

  5. public Ticket enter(){
  6. }
  7. public void exit(){
  8. }
复制代码
以下为OA的代码。Input和Output。
  1. package hopper;

  2. import java.io.BufferedReader;
  3. import java.io.InputStreamReader;
  4. import java.util.ArrayList;
  5. import java.util.List;
  6. import java.util.OptionalInt;

  7. interface InputObject {
  8.     String getText();

  9.     OptionalInt getLabel();
  10. }

  11. class Output implements InputObject {
  12.     private final String text;
  13.     private final OptionalInt label;

  14.     public Output(String text) {
  15.         this.text = text;
  16.         this.label = OptionalInt.empty();
  17.     }

  18.     public Output(String text, int label) {
  19.         this.text = text;
  20.         this.label = OptionalInt.of(label);
  21.     }

  22.     public String toString() {
  23.         return String.format("Output(text='%s', label=%d)", this.text, this.label);
  24.     }

  25.     public String getText() {
  26.         return this.text;
  27.     }

  28.     public OptionalInt getLabel() {
  29.         return this.label;
  30.     }
  31. }

  32. class Answer implements InputObject {
  33.     private final String text;

  34.     public Answer(String text) {
  35.         this.text = text;
  36.     }

  37.     public String toString() {
  38.         return String.format("Answer(text='%s')", this.text);
  39.     }

  40.     public String getText() {
  41.         return this.text;
  42.     }

  43.     public OptionalInt getLabel() {
  44.         throw new UnsupportedOperationException();
  45.     }
  46. }

  47. class Conclusion implements InputObject {
  48.     private final String text;

  49.     public Conclusion(String text) {
  50.         this.text = text;
  51.     }

  52.     public String toString() {
  53.         return String.format("Conclusion(text='%s')", this.text);
  54.     }

  55.     public String getText() {
  56.         return this.text;
  57.     }

  58.     public OptionalInt getLabel() {
  59.         throw new UnsupportedOperationException();
  60.     }
  61. }

  62. class Goto implements InputObject {
  63.     private final int label;

  64.     public Goto(int label) {
  65.         this.label = label;
  66.     }

  67.     public String toString() {
  68.         return String.format("Goto(label=%d)", this.label);
  69.     }

  70.     public String getText() {
  71.         throw new UnsupportedOperationException();
  72.     }

  73.     public OptionalInt getLabel() {
  74.         return OptionalInt.of(this.label);
  75.     }
  76. }

  77. class IndentationAndInputObject {
  78.     private final int indentation;
  79.     private final InputObject inputObject;

  80.     public IndentationAndInputObject(int indentation, InputObject inputObject) {
  81.         this.indentation = indentation;
  82.         this.inputObject = inputObject;
  83.     }

  84.     public String toString() {
  85.         return String.format("IndentationAndInputObject(indentation=%d, inputObject=%s)", this.indentation, this.inputObject);
  86.     }

  87.     public int getIndentation() {
  88.         return this.indentation;
  89.     }

  90.     public InputObject getInputObject() {
  91.         return this.inputObject;
  92.     }
  93. }

  94. public class Solution {
  95.     public static final String HOPPER_MESSAGE_PREFIX = "Hopper: ";
  96.     public static final String USER_MESSAGE_PREFIX = "User: ";
  97.     public static final String CONCLUSION_MESSAGE_PREFIX = "Conclusion: ";

  98.     public void printConversation(List<IndentationAndInputObject> flatTree, List<String> userAnswers) {
  99.         // Write your solution below
  100.         // Some example code is provided to show you how to access our data structures, feel free to modify/delete
  101.         for (IndentationAndInputObject iaio : flatTree) {
  102.             if (iaio.getInputObject() instanceof Output) {
  103.                 System.out.println(HOPPER_MESSAGE_PREFIX + iaio.getInputObject().getText());
  104.             } else if (iaio.getInputObject() instanceof Answer) {
  105.                 System.out.println(USER_MESSAGE_PREFIX + iaio.getInputObject().getText());
  106.             } else if (iaio.getInputObject() instanceof Conclusion) {
  107.                 System.out.println(CONCLUSION_MESSAGE_PREFIX + iaio.getInputObject().getText());
  108.             }
  109.         }
  110.     }

  111.     public IndentationAndInputObject parseLine(String line) {
  112.         int indentation = line.indexOf(line.trim());
  113.         return new IndentationAndInputObject(indentation, parseInputObject(line.substring(indentation)));
  114.     }

  115.     public InputObject parseInputObject(String line) {
  116.         if (line.charAt(0) == '-') {
  117.             return new Answer(line.substring(1));
  118.         } else if (line.charAt(0) == '=') {
  119.             return new Conclusion(line.substring(1));
  120.         } else if (line.charAt(0) == '>') {
  121.             return new Goto(Integer.parseInt(line.substring(1)));
  122.         } else {
  123.             return parseOutput(line);
  124.         }
  125.     }

  126.     public Output parseOutput(String line) {
  127.         boolean labelFound = false;
  128.         int labelDelimiter = -1;
  129.         for (int i = 0; i < line.length(); i++) {
  130.             if (!Character.isDigit(line.charAt(i))) {
  131.                 if (line.charAt(i) == ':') {
  132.                     labelFound = true;
  133.                     labelDelimiter = i;
  134.                 }
  135.                 break;
  136.             }
  137.         }

  138.         if (labelFound) {
  139.             return new Output(line.substring(labelDelimiter + 1), Integer.parseInt(line.substring(0, labelDelimiter)));
  140.         } else {
  141.             return new Output(line);
  142.         }
  143.     }

  144.     public static void main(String args[]) throws Exception {
  145.         try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
  146.             Solution solution = new Solution();

  147.             String line;
  148.             boolean processingExamples = false;
  149.             List<String> userAnswers = new ArrayList<>();
  150.             List<IndentationAndInputObject> flatTree = new ArrayList<>();

  151.             while ((line = reader.readLine()) != null) {
  152.                 if (line.equals("---")) {
  153.                     processingExamples = true;
  154.                 } else if (processingExamples) {
  155.                     userAnswers.add(line);
  156.                 } else {
  157.                     flatTree.add(solution.parseLine(line));
  158.                 }
  159.             }

  160.             solution.printConversation(flatTree, userAnswers);
  161.         }
  162.     }
  163. }
复制代码
  1. Hello, John! It looks like you booked a Basic Economy flight.
  2. Are you aware that this flight doesn't have any storage for carry-on luggage?
  3. -No
  4.   Some other limitations you may want to consider is that you will not be able to pick a seat.
  5.   We're happy to let you know that we can upgrade you today for just $25!
  6.   Would you like to do that now?
  7.    -Not right now
  8.     =Okay, please let our customer service team know if you change your mind.
  9.    -Yes, please upgrade
  10.     =Okay, you've been upgraded!
  11. -Yes
  12.   We're happy to let you know that we can upgrade you today for just $25!
  13.   Would you like to do that now?
  14.    -Not right now
  15.     =Okay, please let our customer service team know if you change your mind.
  16.    -Yes, please upgrade
  17.     =Okay, you've been upgraded!
  18. ---
  19. No
  20. Not right now
复制代码
  1. Hopper: Hello, John! It looks like you booked a Basic Economy flight.
  2. Hopper: Are you aware that this flight doesn't have any storage for carry-on luggage?
  3. User: No
  4. Hopper: Some other limitations you may want to consider is that you will not be able to pick a seat.
  5. Hopper: We're happy to let you know that we can upgrade you today for just $25!
  6. Hopper: Would you like to do that now?
  7. User: Not right now
  8. Conclusion: Okay, please let our customer service team know if you change your mind.
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x

评分

参与人数 3大米 +32 收起 理由
清道神君 + 30
Hanker + 1 欢迎分享你知道的情况,会给更多积分奖励!
籍籍无名的少年 + 1 赞一个

查看全部评分


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

本版积分规则

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