Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinxuv committed Jun 2, 2019
1 parent ca677e0 commit 4a02c5d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions solutions/system_design/pastebin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ To generate the unique url, we could:
* Base 64 is another popular encoding but provides issues for urls because of the additional `+` and `/` characters
* The following [Base 62 pseudocode](http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener) runs in O(k) time where k is the number of digits = 7:

```
```python
def base_encode(num, base=62):
digits = []
while num > 0
Expand All @@ -142,13 +142,13 @@ def base_encode(num, base=62):

* Take the first 7 characters of the output, which results in 62^7 possible values and should be sufficient to handle our constraint of 360 million shortlinks in 3 years:

```
```python
url = base_encode(md5(ip_address+timestamp))[:URL_LENGTH]
```

We'll use a public [**REST API**](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest):

```shell
```
$ curl -X POST --data '{ "expiration_length_in_minutes": "60", \
"paste_contents": "Hello World!" }' https://pastebin.com/api/v1/paste
```
Expand Down Expand Up @@ -182,8 +182,8 @@ Response:

```
{
"paste_contents": "Hello World",
"created_at": "YYYY-MM-DD HH:MM:SS",
"paste_contents": "Hello World"
"created_at": "YYYY-MM-DD HH:MM:SS"
"expiration_length_in_minutes": "60"
}
```
Expand All @@ -194,7 +194,7 @@ Since realtime analytics are not a requirement, we could simply **MapReduce** th

**Clarify with your interviewer how much code you are expected to write**.

```
```python
class HitCounts(MRJob):

def extract_url(self, line):
Expand Down

0 comments on commit 4a02c5d

Please sign in to comment.