Phone Interview
HTTP Header
Link: https://www.1point3acres.com/bbs/thread-777968-1-1.html
Part I
Accept-Language: en-US, fr-CA, fr-FR
means that the reader would accept:
- English as spoken in the United States (most preferred)
- French as spoken in Canada
- French as spoken in France (least preferred)
Write a function that receives two arguments: an Accept-Language header value as a string and a set of supported languages, and returns the list of language tags that will work for the request. The language tags should be returned in descending order of preference (the same order as they appeared in the header).
In addition to writing this function, you should use tests to demonstrate that it’s correct, either via an existing testing system or one you create.
Examples:
1 | parse_accept_language( |
1 | def parse_accept_language(s, languages): -> list<str> |
Wish list
1 | // Step 1) |
Currency conversion
讀取一個string, 實現currency conversion相關的需求
例子: USD:AUD:1.4,CAD:USD:0.8,USD:JPY:110
Part 1: 給定一組currency code, 如果input string裏有直接記錄conversion rate的話, 返回該conversion rate
Part 2: 如果conversion rate可經由一次轉換計算岀來(如CAD:AUD), 也需返回
Part 3: 計算Part 2中的conversion rate時, 需用”best conversion calculation available”
Part 4: 應能返回所有可從input string計算岀的conversion rate pairs
貨幣兌換是需要雙向的
i was also asked the same question. Make sure to use BFS when they ask you to convert a currency. It will help to solve the follow up questions. And be fast while coding.
Feature
1 | Consider a system of User and Feature objects, where a Feature describes the availability of |
Fraud Rule
1 | Certain colleagues upstairs have let us know that our policy of approving every Authorization Request is frowned upon by our investors. Luckily, they informed us of a separate system that our data science department built which can detect Authorization Requests that are fraudulent. With fraud, the data scientists say, nothing is set in stone. The criteria for fraud change constantly, so their system develops new Fraud Rules all the time. They’ve given us access to their system’s stream of Fraud Rules, in the following format: |
Server removal time
1 | Throughout this interview, we'll write code to analyze a simple server process uptime log. These logs are much simplified, and are just strings of space separated 0's and 1's. The log is a string of binary digits (e.g. "0 0 1 0"). Each digit corresponds to 1 hour of the server running: |
Store Penalty
1 | # For the purposes of this interview, imagine that we own a store. This |
Account Balance
https://github.com/stripe-interview/python-interview-prep
地里常见题。这一轮之前面试官会先给你share一个repo(🔗 github.com),让你本地测试下有没有问题,保证之后integration和bug squash不用额外花时间setup,然而之后的面试并不会用到这个repo
https://leetcode.com/problems/optimal-account-balancing/description/
At Stripe we keep track of where the money is and move money between bank accounts to make sure their balances are not below some threshold. This is for operational and regulatory reasons, e.g. we should have enough funds to pay out to our users, and we are legally required to separate our users’ funds from our own. This interview question is a simplified version of a real-world problem we have here.
Let’s say there are at most 500 bank accounts, some of their balances are above 100 and some are below. How do you move money between them so that they all have at least 100?
Just to be clear we are not looking for the optimal solution, but a working one.
Example input:
- AU: 80
- US: 140
- MX: 110
- SG: 120
- FR: 70
Output: - from: US, to: AU, amount: 20
- from: US, to: FR, amount: 20
- from: MX, to: FR, amount: 10
写完还有时间,问了followup:
followup1:反过来问,假设给你一系列transfer,问最后account balance是否满足条件。假设所给account balance无论如何也无法做到每个account>=100,问所给的transfer是不是best effort?
followup2:如何得到最优解?这里你需要问面试官如何定义最优解。面试官说转账次数越少越好。这样和蠡口撕柳芜就很像了
followup都只用说思路,不用写
Onsite
Coding
integration
bikemap
Debug
mako
- filesystem
- comment, ast
- exception type
- template match
Debug
也是新题。用的是 https://github.com/jbeder/yaml-cpp 。一共2题,据面试官说都是这个repo里实际出现过的bug
- parse tag出了问题:yaml tag允许包含括号,但是他给的这个版本有bug,一碰到括号就误以为tag结束了
Debug
https://github.com/square/moshi
System Design
System Design - ledger
Stripe is a payments platform that provides the ability for online businesses to charge money from customers and then get paid out periodically.
For example a Stripe merchant called ShirtyPuff runs a website that sells t-shirts. Every time one of ShirtyPuff’s customers buys a t-shirt we collect money on behalf of the merchant. Periodically we pay the merchant an amount which is calculated by aggregating all the transactions.
There are other teams that take care of building software for actually sending and receiving money.
Your aim is to build a bookkeeping service (called Ledger) that keeps track of money sent and money received on behalf of a merchant. The purpose of this service is to record all financial activity and allow getting the account balance for a given merchant.
The Ledger should support the following operations:
- Record money sent or received on behalf of a merchant
- Get account balance for a given merchant
What APIs would you build for a system like this?
How would you go about building this system?
https://tianpan.co/notes/166-designing-payment-webhook
System Design - metrics counter
1 | Imagine you work at a startup with many copies of many different services |
Sample System Diagram
1 | +---------------+ |
设计一个仓库系统存储注册与登录的信息
link: https://www.1point3acres.com/bbs/thread-1048108-1-1.html
问的是仓储 记录这些登录登出
similar to youtube view