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

Stripe店面挂经

全局:

2022(1-3月) 码农类General 硕士 全职@stripe - 猎头 - 技术电面  | 🙁 Negative 🙂 Easy | Fail | 在职跳槽

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

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

x
题目就是:

上午面完,下午就收到模版拒信,挺有效率的。面试体验很一般,面试官上来就说不要求优化,你想优化的随意,我们主要看你的思路和交流。
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
case就对了!但这种风气感觉是在无法认同,所以被拒也是双方都解脱了

评分

参与人数 1大米 +4 收起 理由
匿名用户-NB8O9 + 4

查看全部评分


上一篇:电动车Rivian店面
下一篇:#zip招聘店面
🔗
ShiDong 2022-2-21 22:52:34 | 只看该作者
全局:
这种基本是模拟工作面试吧, 测试在fintech公司的工作过程中挺重要的
回复

使用道具 举报

🔗
JBGood 2022-3-17 00:28:12 | 只看该作者
全局:
解决方案
  1. #include <iostream>
  2. #include <string>
  3. #include <unordered_map>
  4. #include <vector>
  5. #include <queue>
  6. #include <algorithm>

  7. using namespace std;


  8. /**
  9. *
  10. *  TEST
  11. *
  12. *  */
  13. class Test{
  14.     public:
  15.     static int totalCase;
  16.     static int testCase;
  17.     Test(bool expected, bool result);
  18.     Test(vector<string> expected, vector<string> result);
  19.     void printVector(vector<string> v);
  20.     static void printTestSuit(); // to directly access Test::printTestSuit() in main
  21. };
  22. int Test::totalCase = 0;
  23. int Test::testCase = 0;

  24. Test::Test(bool expected, bool result){
  25.     totalCase++;
  26.     if(result == expected){
  27.         cout << "Test Passed : " << "(expected: " << expected << ", result: " << result << ")" << endl;
  28.         testCase++;
  29.     }
  30.     else {
  31.         cout << "Test Failed : " << "(expected: " << expected << ", result: " << result << ")" << endl;   
  32.     }
  33. }
  34. Test::Test(vector<string> expected, vector<string> result){
  35.     totalCase++;
  36.      if(expected == result){
  37.         cout << "Test Passed : " << "(expected: "; printVector(expected);  cout << ", result: "; printVector(result); cout << ")" << endl;
  38.         testCase++;
  39.     } else {
  40.         cout << "Test Failed : " << "(expected: "; printVector(expected); cout << ", result: "; printVector(result); cout << ")" << endl;   
  41.     }
  42. }

  43. void Test::printVector(vector<string> v){
  44.     cout << "{";
  45.     for(int i = 0; i < v.size() - 1; i++){
  46.         cout << v[i] << ", ";
  47.     }
  48.     cout << v[v.size() - 1] << "}";
  49. }

  50. void Test::printTestSuit(){
  51.     cout << testCase << " / " << totalCase <<  " Total Cases Passed" << endl;
  52. }

  53. /**
  54. *
  55. *  WISHLIST
  56. *
  57. *  */
  58. class WishList{
  59.     public:
  60.     unordered_map<string, vector<string>> wishList = {
  61.         {"a", {"c", "d"}},
  62.         {"b", {"d", "a", "c"}},
  63.         {"c", {"a", "b"}},
  64.         {"d", {"c", "a", "b"}},
  65.         {"e", {""}}

  66.         // {"a", {"b", "c", "d"}},
  67.         // {"b", {"a", "d", "c"}},
  68.         // {"c", {"d" ,"a", "b"}},
  69.         // {"d", {"a", "c"}}

  70.         // {"a", {"c", "d"}},
  71.         // {"b", {"d", "a", "c"}},
  72.         // {"c", {"a", "b"}},
  73.         // {"d", {"c", "a", "b"}}
  74.         

  75.     };
  76.     bool has_mutual_first_choice(string userName);
  77.     bool has_mutual_pair_for_rank(string userName, int rank);
  78.     bool has_mutual_pair_for_rank(string userName, int uRank, int mRank);
  79.     vector<string> changePair(string user, int index);
  80.     vector<string> changed_pairings(string userName, int index);
  81. };

  82. // part 1
  83. bool WishList::has_mutual_first_choice(string userName){
  84.     if(!wishList[userName].empty() && wishList.find(userName) != wishList.end()){
  85.         const int firstChoice = 0;
  86.         string usersFirstChoice = wishList[userName][firstChoice];
  87.         if(wishList.find(usersFirstChoice) != wishList.end()
  88.             && !wishList[usersFirstChoice].empty()
  89.             && wishList[usersFirstChoice][firstChoice] == userName){
  90.             return true;
  91.         }
  92.     }
  93.     return false;
  94. }

  95. // part 2
  96. bool WishList::has_mutual_pair_for_rank(string userName, int rank){
  97.     if(wishList[userName].size() > rank && wishList.find(userName) != wishList.end()){
  98.         string usersChoice = wishList[userName][rank];
  99.         if(wishList.find(usersChoice) != wishList.end()
  100.             && wishList[usersChoice].size() > rank
  101.             && wishList[usersChoice][rank] == userName)
  102.             return true;
  103.     }
  104.     return false;
  105. }


  106. bool WishList::has_mutual_pair_for_rank(string user, int uRank, int mRank){
  107.     if(uRank < 0) return false;
  108.     if(wishList[user].size() > uRank && wishList.find(user) != wishList.end()){
  109.         string mutualUser = wishList[user][uRank];
  110.         if(wishList.find(mutualUser) != wishList.end()
  111.             && wishList[mutualUser].size() > mRank
  112.             && wishList[mutualUser][mRank] == user)
  113.             return true;
  114.     }

  115.     return false;
  116. }

  117. // part 3-1 - swap user rank index with index-1
  118. vector<string> WishList::changePair(string user, int index){
  119.     // return matched all users before and after swap with same mutual ranking
  120.     vector<string> ans;
  121.     // before swap
  122.     if(wishList[user].size() > index && wishList.find(user) != wishList.end()){
  123.         vector<string> usersWishlist {wishList[user]};
  124.         for(int i = 0 ; i < usersWishlist.size(); i++){
  125.             if(has_mutual_pair_for_rank(user, i))
  126.                 ans.push_back(usersWishlist[i]);
  127.         }
  128.         // after swap
  129.         if(index > 0){
  130.             if(has_mutual_pair_for_rank(user, index, index - 1))
  131.                 ans.push_back(usersWishlist[index]);

  132.             if(has_mutual_pair_for_rank(user, index - 1, index))
  133.                 ans.push_back(usersWishlist[index - 1]);
  134.         }
  135.     }
  136.     return ans;
  137. }


  138. vector<string> WishList::changed_pairings(string userName, int index){
  139.     // before swap
  140.     vector<string> ans;
  141.     if(wishList[userName].size() > index && wishList.find(userName) != wishList.end()){
  142.         vector<string> usersWishList {wishList[userName]};
  143.         if(index > 0){
  144.             if(has_mutual_pair_for_rank(userName, index) != has_mutual_pair_for_rank(userName, index, index - 1))
  145.                 ans.push_back(usersWishList[index]);

  146.             if(has_mutual_pair_for_rank(userName, index - 1) != has_mutual_pair_for_rank(userName, index - 1, index))
  147.                 ans.push_back(usersWishList[index - 1]);
  148.         }
  149.     }
  150.     if(ans.empty()) return {""};
  151.     return ans;
  152. }





  153. int main(){

  154.     WishList* wishList = new WishList();




  155.     Test(1, wishList->has_mutual_first_choice("a"));
  156.     Test(1, wishList->has_mutual_first_choice("c"));
  157.     Test(0, wishList->has_mutual_first_choice("b"));

  158.     Test(1, wishList->has_mutual_pair_for_rank("a", 1));
  159.     Test(1, wishList->has_mutual_pair_for_rank("a", 0));

  160.     Test({"a","b","d"}, wishList->changePair("c", 1));

  161.     Test({"a"}, wishList->changed_pairings("d", 1));
  162.     Test({"c"}, wishList->changed_pairings("b", 2));
  163.     Test({""}, wishList->changed_pairings("b", 1));


  164.     Test::printTestSuit();

  165.     return 0;
  166. }
复制代码
回复

使用道具 举报

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

本版积分规则

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