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

Stripe OA白嫖到失联

全局:

2019(10-12月) 码农类General 本科 全职@stripe - 网上海投 - 在线笔试  | | Other | 其他
最近白嫖到失联,不知道什么时候才能上岸
附上stripe oa代码和自己的测试,通过所有testcase,不过自己hardcode了很多地方,只做为参考。
您好!
本帖隐藏的内容需要积分高于 180 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 180 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies



本帖子中包含更多资源

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

x

评分

参与人数 13大米 +26 收起 理由
yyanguestc + 2 欢迎分享你知道的情况,会给更多积分奖励!
halloweenyolo + 2 给你点个赞!
匿名用户-SUYDG + 10
xw6938 + 1 给你点个赞!
wirehack + 1 给你点个赞!

查看全部评分


上一篇:peak6校园面试
下一篇:【新鲜出炉】Amazon三轮vo
推荐
 楼主| sanguobusha 2019-10-9 11:05:04 | 只看该作者
全局:
xinyuw 发表于 2019-10-8 14:31
楼主,附件下载了但是打开是乱码啊。我用的mamp开的
  1. package stripeOA;

  2. import java.util.ArrayList;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import java.util.*;
  7. public class Solution {
  8.    
  9.     public static void main(String[] args) {
  10.         List<String> test1 = new ArrayList<>();
  11.         test1.add("CREATE: id=13&amount=800&currency=USD");
  12.         System.out.println("test1: " + compute(test1)); //800

  13.         List<String> test2 = new ArrayList<>();
  14.         test2.add("CREATE: id=16&amount=800&currency=USD");
  15.         test2.add("FINALIZE: id=16&amount=600&currency=USD");
  16.         System.out.println("test2: " + compute(test2));//600
  17.         
  18.         List<String> test3 = new ArrayList<>();
  19.         test3.add("CREATE: id=16&amount=800&currency=USD");
  20.         test3.add("FINALIZE: id=16&amount=600&currency=USD");
  21.         test3.add("CREATE: id=13&amount=800&currency=USD");
  22.         System.out.println("test3: " + compute(test3));//1400
  23.         
  24.         List<String> test4 = new ArrayList<>();
  25.         test4.add("CREATE: id=16&amount=800&currency=USD");
  26.         test4.add("FINALIZE: id=16&amount=600&currency=USD");
  27.         test4.add("PAY: id=16");
  28.         System.out.println("test4: " + compute(test4));//0
  29.         
  30.         List<String> test5 = new ArrayList<>();
  31.         test5.add("CREATE: amount=800&id=16&currency=USD");
  32.         test5.add("FINALIZE: id=16&amount=600&currency=USD&otherfield=a");
  33.         test5.add("PAY: otherfield=a&id=16");
  34.         System.out.println("test5: " + compute(test5));//0
  35.         
  36.         List<String> test6 = new ArrayList<>();
  37.         test6.add("CREATE: amount=800&id=16&currency=USD");
  38.         test6.add("FINALIZE: id=16&amount=600&currency=US");
  39.         System.out.println("test6: " + compute(test6));//800
  40.         test6.add("PAY: id=16");
  41.         System.out.println("test6: "+compute(test6)); // 800
  42.         
  43.         
  44.         List<String> test7 = new ArrayList<>();
  45.         test7.add("Random action");
  46.         System.out.println("test7: " + compute(test7));//0
  47.         
  48.         List<String> test8 = new ArrayList<>();
  49.         test8.add("CREATE: id=16&amount=800&currency=USD");
  50.         test8.add("FINALIZE: id=16&amount=600&currency=USD");
  51.         test8.add("PAY: id=16");
  52.         test8.add("CREATE: id=16&amount=800&currency=USD");
  53.         System.out.println("test8: " + compute(test8));//0
  54.         
  55.         List<String> test9 = new ArrayList<>();
  56. //        test9.add("FINALIZE: id=16&amount=800&currency=USD");
  57.         test9.add("CREATE: id=14&amount=500&currency=RMB");
  58.         test9.add("CREATE: id=15&amount=500&currency=USD");
  59.         test9.add("FINALIZE: id=14&amount=600&currency=USD");
  60.         test9.add("FINALIZE: id=15&amount=400&currency=USD");
  61. //        test9.add("PAY: id=16");

  62.         System.out.println("test9: " + compute(test9));//0
  63.         

  64.         
  65.     }
  66.    
  67.    
  68.     public static int compute(List<String> input) {
  69.         
  70.         Map<String, Invoice> map = new HashMap<>();
  71.         int re = 0;
  72.         
  73.         for(String s : input) {
  74.             String[] arr = s.split(":");
  75.             String state = arr[0].trim();

  76.             if(state.equals("CREATE")) {
  77.                 Invoice in = getInvoice(arr[1]);
  78.                 if(in !=null) {
  79.                     if(!map.containsKey(in.id)) {
  80.                         map.put(in.id,in);
  81.                     }      
  82.                 }
  83.                   
  84.             }else if(state.equals("FINALIZE")) {
  85.                 Invoice in = getInvoice(arr[1]);
  86.                 if(in != null) {
  87.                     in.state = "FINALIZE";
  88.                     if(map.containsKey(in.id)) {
  89.                         Invoice temp = map.get(in.id);
  90.                         if(temp.state.equals("CREATE")) {
  91.                             map.put(in.id, in);
  92.                         }

  93.                     }
  94.                 }
  95.                
  96.                
  97.             }else if(state.equals("PAY")) {
  98.                 String id = payInvoice(arr[1]);
  99.                 if(map.containsKey(id)) {
  100.                     Invoice in = map.get(id);
  101.                     if(in.state.equals("FINALIZE")){
  102.                         in.amount = "0";
  103.                         in.state = "PAY";
  104.                         map.put(id, in);
  105.                     }
  106.                 }
  107.             }
  108.             
  109.         }
  110.         for(String id: map.keySet()) {
  111.             Invoice in = map.get(id);
  112.             int amount = Integer.valueOf(in.amount);
  113.             re+=amount;
  114.         }
  115.         
  116.         
  117.         
  118.         return re;
  119.         
  120.     }
  121.    
  122.     public static Invoice getInvoice(String s) {
  123.         String[] infos = s.split("&");
  124.         String id = null;
  125.         String amount = null;
  126.         String currency =null;
  127.         Invoice invoice = null;
  128.         for(String info : infos) {
  129.             char[] ch = info.toCharArray();
  130.             StringBuilder sb = new StringBuilder();
  131.             if(info.contains("id=")) {
  132.                 int index = info.indexOf("id=");
  133.                 id = handleInfo(index+3,info);
  134.             }else if(info.contains("amount=")) {
  135.                 int index = info.indexOf("amount=");
  136.                 amount = handleInfo(index+7,info);
  137.             }else if(info.contains("currency=")) {
  138.                 int index = info.indexOf("currency=");
  139.                 currency = info.substring(index+9, info.length());
  140.             }
  141.         }
  142.         if(id !=null && amount !=null && currency.equals("USD")) {
  143.             invoice = new Invoice(id,amount,currency, "CREATE");
  144.         }
  145.         
  146.         return invoice;
  147.     }
  148.    
  149.     public static String payInvoice(String s) {
  150.         
  151.         int index = s.indexOf("id=");
  152.         StringBuilder sb = new StringBuilder();
  153.         char[] ch = s.toCharArray();
  154.         for(int i = index+3;i<ch.length;i++) {
  155.             if(Character.isDigit(ch[i]))sb.append(ch[i]);
  156.             else break;
  157.         }
  158.         return sb.toString();
  159.         
  160.     }
  161.    
  162.     public static String handleInfo(int index, String s) {
  163.         char[] ch = s.toCharArray();
  164.         StringBuilder sb = new StringBuilder();
  165.         for(int i = index; i<ch.length;i++) {
  166.             if(Character.isDigit(ch[i]))sb.append(ch[i]);
  167.             else break;
  168.         }
  169.         
  170.         return sb.toString();
  171.     }
  172.    
  173.    
  174.    
  175.    

  176. }


  177. class Invoice {
  178.     String id;
  179.     String amount;
  180.     String currency;
  181.     String state;
  182.     Invoice(String id, String amount, String currency, String state){
  183.         this.id = id;
  184.         this.amount = amount;
  185.         this.currency = currency;
  186.         this.state = state;
  187.     }
  188. }
复制代码
回复

使用道具 举报

推荐
xw6938 2019-10-15 22:58:54 | 只看该作者
全局:
sanguobusha 发表于 2019-10-9 11:05
[mw_shl_code=java,true]package stripeOA;

import java.util.ArrayList;

楼主代码里test 9的注释里可能笔误写错了,答案应该是400才对
回复

使用道具 举报

推荐
xinyuw 2019-10-10 01:31:35 | 只看该作者
全局:
sanguobusha 发表于 2019-10-9 11:05
[mw_shl_code=java,true]package stripeOA;

import java.util.ArrayList;

非常感谢了🙏,楼主好人!
回复

使用道具 举报

🔗
xinyuw 2019-10-8 14:31:16 | 只看该作者
全局:
楼主,附件下载了但是打开是乱码啊。我用的mamp开的
回复

使用道具 举报

🔗
Judy_922 2019-10-11 12:25:10 | 只看该作者
全局:
请问有音讯了么
回复

使用道具 举报

🔗
 楼主| sanguobusha 2019-10-11 12:32:36 | 只看该作者
全局:

testcase全过,一周后给了拒信
回复

使用道具 举报

🔗
Judy_922 2019-10-11 23:54:47 | 只看该作者
全局:
sanguobusha 发表于 2019-10-11 12:32
testcase全过,一周后给了拒信

果然白嫖oa名不虚传。。。我还以为她们选过resume
回复

使用道具 举报

🔗
kariwswww 2019-10-12 12:05:30 | 只看该作者
全局:
求问楼主test case 9是怎么通过的呀呜呜呜现在死活过不了
回复

使用道具 举报

🔗
kariwswww 2019-10-12 12:12:41 | 只看该作者
全局:
请问楼主test case9是怎么过的呀?
回复

使用道具 举报

🔗
 楼主| sanguobusha 2019-10-12 12:13:18 来自APP | 只看该作者
全局:
kariwswww 发表于 2019/10/12 12:05:30
求问楼主test case 9是怎么通过的呀呜呜呜现在死活过不了
你看我回复里的test case,基本oa的test case都在里面;你有考虑比如先amount&后id这种顺序,或者有其他的不是create,finalize的action吗?
回复

使用道具 举报

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

本版积分规则

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