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

条纹NG OA

🔗
匿名用户-K6TLW  2021-10-1 01:52:15 |倒序浏览

2021(10-12月) 码农类General 本科 全职@stripe - 网上海投 - 在线笔试  | 😃 Positive 😐 Average | Other | 应届毕业生
本帖最后由 匿名 于 2021-9-30 11:02 编辑

前天做完的条纹OA,考的是Verification,和地里之前发的一样。
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies

求大米过冬啊啊啊啊 !!!


本帖子中包含更多资源

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

x

评分

参与人数 8大米 +13 收起 理由
地里的生活菌 + 6 给你点个赞!
fancz2002 + 1 感谢分享!
Excal1p2 + 1 给你点个赞!
Kurokoooz + 1 很有用的信息!
rinya33 + 1 yyds

查看全部评分


上一篇:FB的电面结果是如何通知的?
下一篇:ADP vGHC2021 VO 挂筋
地里匿名用户
推荐
匿名用户-HJM0R  2021-10-16 03:11:02
奉上一个solution 求米
  1. public class Verification {
  2.   /*
  3.   Question comes from https://www.1point3acres.com/bbs/thread-802430-1-1.html
  4.      each line:
  5.      merchant_id,field_name,field_value'
  6.      merchant_id: unique
  7.      field_name: country:US|JP|FR
  8.                  business_type: individual|company
  9.                  or one of the values from the table below such as
  10.                  first_name, support_email. need not validate field_name
  11.      more info may be provided than is required for verification
  12.     all input are valid
  13.     input line maybe in any order. inputs for different merchants may also be interleaved

  14.     individual table
  15.        fields   country1  country2  country3
  16.                   US        JP        FR
  17.         SSN        x
  18.         tax_id               x         x
  19.     companies table
  20.        fields   country1  country2  country3
  21.                     US        JP        FR
  22.       director_name                      x

  23.   Output
  24.     print one line per merchant_id in lexicographical order
  25.     if all required fields have been provided according to country and business_type
  26.     print
  27.     merchant_id:VERIFIED
  28.     otherwise
  29.     merchant_id:UNVERIFIED:fieldname1,fieldname2,...
  30.     comma separated list of all the required fields not provided for the merchant in lexicographical order
  31.      - any or both of country and business_type
  32.      - those in related tables

  33.    Ex1:
  34.     input
  35.      1
  36.      acct_123,business_type,company
  37.     output
  38.      acct_123:UNVERIFIED:country

  39.    Ex2:
  40.    input:
  41.     8
  42.     acct_123,country,US
  43.     acct_123,business_type,individual
  44.     acct_123,first_name,Jane
  45.     acct_123,last_name,Doe
  46.     acct_123,date_of_birth,01011970
  47.     acct_123,social_security_number,123456789
  48.     acct_123,email,test@example.com
  49.     acct_123,phone,555555555
  50.    output:
  51.     acct_123:VERIFIED

  52.    EX3:
  53.     input:
  54.     12
  55.     acct_123,tax_id_number,12345689
  56.     acct_123,country,FR
  57.     acct_123,business_type,company
  58.     acct_456,business_type,individual
  59.     acct_456,country,JP
  60.     acct_456,first_name,Mei
  61.     acct_456,last_name,Sato
  62.     acct_456,first_name_kana,Mei
  63.     acct_456,last_name_kana,Sato
  64.     acct_456,data_of_birth,01011970
  65.     acct_456,tax_id_number,123456
  66.     acct_456,email,test@example.com

  67.     output
  68.     acct_123:UNVERIFIED:director_name,name,phone
  69.     acct_456:VERIFIED


  70.       */
  71.   // assume it is available,
  72.   // key is country value+" "+business_type,
  73.   // values are required fields sorted in lexicographically order
  74.   private static Map<String, List<String>> required = new HashMap<>();

  75.   static {
  76.     // country individual
  77.     List<String> fs =
  78.         Arrays.asList(
  79.             "first_name", "last_name", "date_of_birth", "social_security_number", "email", "phone");
  80.     Collections.sort(fs);
  81.     required.put("US individual", fs);

  82.     fs =
  83.         Arrays.asList(
  84.             "first_name",
  85.             "last_name",
  86.             "first_name_kana",
  87.             "last_name_kana",
  88.             "date_of_birth",
  89.             "tax_id_number",
  90.             "email");
  91.     Collections.sort(fs);
  92.     required.put("JP individual", fs);

  93.     fs = Arrays.asList("first_name", "last_name", "tax_id_number", "email", "phone");
  94.     Collections.sort(fs);
  95.     required.put("FR individual", fs);
  96.     // country company
  97.     fs = Arrays.asList("name", "employer_id_number", "email", "phone");
  98.     Collections.sort(fs);
  99.     required.put("US company", fs);

  100.     fs = Arrays.asList("name", "tax_id_number", "phone");
  101.     Collections.sort(fs);
  102.     required.put("JP company", fs);

  103.     fs = Arrays.asList("name", "director_name", "tax_id_number", "phone");
  104.     Collections.sort(fs);
  105.     required.put("FR company", fs);
  106.   }

  107.   public static List<String> verify_merchants(List<String> lines) {
  108.     // will keep parsed merchant and provided field value pairs
  109.     Map<String, Map<String, String>> input = new HashMap<>();
  110.     for (String line : lines) {
  111.       String[] cuts = line.split(",");
  112.       input.putIfAbsent(cuts[0], new HashMap<>());
  113.       input.get(cuts[0]).put(cuts[1], cuts[2]);
  114.     }

  115.     List<String> merchants = new ArrayList<>(input.keySet());
  116.     Collections.sort(merchants);

  117.     List<String> r = new ArrayList<>(merchants.size());
  118.     StringBuilder mr;
  119.     for (String m : merchants) {
  120.       Map<String, String> kv = input.get(m);
  121.       mr = new StringBuilder();
  122.       if (!kv.containsKey("country") || !kv.containsKey("business_type")) {
  123.         mr.append(m).append(":UNVERIFIED:");
  124.         if (!kv.containsKey("country")) mr.append("country,");
  125.         if (!kv.containsKey("business_type")) mr.append("business_type,");
  126.         mr.deleteCharAt(mr.length() - 1);
  127.         r.add(mr.toString());
  128.         continue;
  129.       }
  130.       for (String f : required.get(kv.get("country") + " " + kv.get("business_type"))) {
  131.         if (!kv.containsKey(f)) {
  132.           if (mr.isEmpty()) {
  133.             mr.append(m).append(":UNVERIFIED:");
  134.           }
  135.           mr.append(f).append(",");
  136.         }
  137.       }
  138.       if (mr.isEmpty()) r.add(m + ":VERIFIED");
  139.       else {
  140.         mr.deleteCharAt(mr.length() - 1);
  141.         r.add(mr.toString());
  142.       }
  143.     }
  144.     return r;
  145.   }

  146.   public static void main(String[] args) {

  147.     System.out.println(
  148.         Arrays.toString(verify_merchants(Arrays.asList("acct_123,business_type,company")).toArray())
  149.             .equals("[acct_123:UNVERIFIED:country]"));

  150.     System.out.println(
  151.         Arrays.toString(
  152.                 verify_merchants(
  153.                         Arrays.asList(
  154.                             "acct_123,country,US",
  155.                             "acct_123,business_type,individual",
  156.                             "acct_123,first_name,Jane",
  157.                             "acct_123,last_name,Doe",
  158.                             "acct_123,date_of_birth,01011970",
  159.                             "acct_123,social_security_number,123456789",
  160.                             "acct_123,email,test@example.com",
  161.                             "acct_123,phone,555555555"))
  162.                     .toArray())
  163.             .equals("[acct_123:VERIFIED]"));

  164.     System.out.println(
  165.         Arrays.toString(
  166.                 verify_merchants(
  167.                         Arrays.asList(
  168.                             "acct_123,tax_id_number,12345689",
  169.                             "acct_123,country,FR",
  170.                             "acct_123,business_type,company",
  171.                             "acct_456,business_type,individual",
  172.                             "acct_456,country,JP",
  173.                             "acct_456,first_name,Mei",
  174.                             "acct_456,last_name,Sato",
  175.                             "acct_456,first_name_kana,Mei",
  176.                             "acct_456,last_name_kana,Sato",
  177.                             "acct_456,date_of_birth,01011970",
  178.                             "acct_456,tax_id_number,123456",
  179.                             "acct_456,email,test@example.com"))
  180.                     .toArray())
  181.             .equals("[acct_123:UNVERIFIED:director_name,name,phone, acct_456:VERIFIED]"));
  182.   }
  183. }
复制代码
求米

评分

参与人数 2大米 +2 收起 理由
小羊ZNMO + 1 给你点个赞!
sssq36 + 1 很有用的信息!

查看全部评分

回复

使用道具 举报

地里匿名用户
🔗
匿名用户-KJDHM  2021-10-1 01:54:37
谢谢!祝早日上岸

评分

参与人数 1大米 +1 收起 理由
whenigetsad + 1 赞一个

查看全部评分

回复

使用道具 举报

🔗
lulululuev 2021-10-1 04:46:30 | 只看该作者
全局:
感谢楼主分享
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-8JZDK  2021-10-8 23:44:44
求楼主时间线
回复

使用道具 举报

🔗
P1nk_Ba8y 2021-11-15 12:49:32 | 只看该作者
全局:
匿名者 发表于 2021-10-15 14:11
奉上一个solution 求米求米

mr.isEmpty() 改成mr.length() == 0
回复

使用道具 举报

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

本版积分规则

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