回复: 1
收起左侧

路公平店面redo过经

本楼:   👍  0
0%
0%
0   👎
全局:   69
99%
1%
1

2022(1-3月) 码农类General 硕士 全职@wayfair - 网上海投 - 技术电面  | 😃 Positive 😣 Hard | Pass | 在职跳槽

注册一亩三分地论坛,查看更多干货!

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

x
本帖最后由 nedved 于 2022-4-2 18:32 编辑

karat,面试官比较冷漠。。
开始是设计五小题,地里都有。

代码题我感觉还是有点难度对于我(lc只刷了100来道题),还好最后做出来了。
编程题如下:
/**
You're developing a system for scheduling advising meetings with students in a Computer Science program. Each meeting should be scheduled when a student has completed 50% of their academic program.

Each course at our university has at most one prerequisite that must be taken first. No two courses share a prerequisite. There is only one path through the program.

您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式

Sample output 1:
"Data Structures"


Sample input 2:
prereqs_courses2 = [
    ["Algorithms", "Foundations of Computer Science"],
    ["Data Structures", "Algorithms"],
    ["Foundations of Computer Science", "Logic"],
    ["Logic", "Compilers"],
    ["Compilers", "Distributed Systems"],
]


Sample output 2:
"Foundations of Computer Science"

Sample input 3:
prereqs_courses3 = [
["Data Structures", "Algorithms"],
]


Sample output 3:
"Data Structures"

Complexity analysis variables:

n: number of pairs in the input

*/

import java.io.*;
import java.util.*;

public class Solution {
  public static void main(String[] argv) {
    String[][] prereqsCourses1 = {
        {"Foundations of Computer Science", "Operating Systems"},
        {"Data Structures", "Algorithms"},
        {"Computer Networks", "Computer Architecture"},
        {"Algorithms", "Foundations of Computer Science"},
        {"Computer Architecture", "Data Structures"},
        {"Software Design", "Computer Networks"}
    };

    String[][] prereqsCourses2 = {
        {"Algorithms", "Foundations of Computer Science"},
        {"Data Structures", "Algorithms"},
        {"Foundations of Computer Science", "Logic"},
        {"Logic", "Compilers"},
        {"Compilers", "Distributed Systems"},
    };


    String[][] prereqsCourses3 = {
        {"Data Structures", "Algorithms"}
    };

    System.out.println(findHalfway(prereqsCourses3));

  }

  public static String findHalfway (String[][] courses) {
  }
}

答案:(recruiter反馈我的解法是optimal solution)
  1. </blockquote></div><div class="blockcode"><blockquote>public static String findHalfway (String[][] courses) {
  2.       LinkedList<String> lst = new LinkedList<>();
  3.       int x = courses.length;
  4.       // assume there is always records.

  5.       //"Data Structures" -> "Algorithms" -> "Foundations of Computer Science" -> "Operating Systems"

  6.       Map<String, String> ba = new HashMap<>();
  7.       Map<String, String> ab = new HashMap<>();
  8.       for(int i=0; i<x; i++) {
  9.         String before = courses[i][0];
  10.         String after = courses[i][1];
  11.         ba.put(before, after);
  12.         ab.put(after, before);
  13.       }

  14.       lst.add(courses[0][0]);
  15.       lst.add(courses[0][1]);

  16.       for(int j=1; j<x; j++){
  17.         String head = lst.getFirst();
  18.         String tail = lst.getLast();
  19.         if(ab.get(head) != null) {
  20.           lst.addFirst(ab.get(head));
  21.         }
  22.         if(ba.get(tail) != null) {
  23.           lst.addLast(ba.get(tail));
  24.         }
  25.       }
  26.       return lst.get(x/2);
  27.   }
复制代码
求求求大米!~~








上一篇:买它 地里近1-4周手翻高频总结 求米!!
下一篇:平方店面
小亩_tfmt7vo 2024-10-29 19:22:13 | 显示全部楼层
本楼:   👍  0
0%
0%
0   👎
全局:   28
100%
0%
0
谢谢分享!!
回复

使用道具 举报

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

本版积分规则

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