☕ Visa uses Crypto

A solution to yesterday's interview question on sorting a 100 gigabyte file. Plus, Visa announces support for a stablecoin based on the Ethereum blockchain. We break down what that means.

Hey Guys,

Interviewing.io is a fantastic resource I wanted to share with you all.

You can book realistic mock interviews with senior FAANG engineers who will give you detailed and actionable feedback on exactly what you need to work on.

Mastering algorithms on LeetCode and system design on SystemsExpert is great, but they don’t prepare you for the pressure and stress that comes from an actual interview setting.

The best part?

You don’t pay anything until you’re hired.

Check them out here.

Special thanks to Interviewing.io for sponsoring Quastor Daily. I’m a user of the service!

Industry News

Visa announces that it will allow transactions to be settled using the stablecoin USDC (USD Coin)

USDC is a stablecoin (pegged to the US Dollar in a 1:1 ratio) that runs on top of the Ethereum blockchain. It is currently the fastest growing dollar digital currency in the world and has a market cap of more than $10 billion dollars.

Every dollar of USDC is backed by $1 of US treasury bonds held in reserve.

Visa currently maintains one of the largest payment systems in the world, processing more than 1,500 transactions per second (TPS).

Now, Visa will use their payment network to transfer USDC and will do settlement of those payments on the Ethereum Blockchain.

The Ethereum network doesn’t have a TPS anywhere near as high, which is why Visa is using the blockchain as a “final settlement” mechanism.

To quote Bankless, “Thousands of USDC transactions can happen internally on Visa’s network, and then Visa can make a single, batched transaction to Ethereum that updates the balances of it’s partners that leverage Visa for USDC transfers.”

Now, a customer who holds USDC in a wallet (and has a Visa card attached to their wallet) can spend at any Visa accepting merchant, with USDC being used to settle the transaction. An example of such a wallet-attached card is the Crypto.com Visa card.

Previously, if you wanted to purchase a sandwich with your Crypto.com Visa card, the digital currency held in your wallet would have to be converted to fiat money (traditional dollars).

Visa’s latest steps means that there is no longer a need to do the conversion to fiat.

Interview Question

Given two straight line segments (represented as a start point and an end point), compute the point of intersection (if it exists).

We’ll send a detailed solution tomorrow, so make sure you move our emails to primary, so you don’t miss them!

Gmail users—move us to your primary inbox

  • On your phone? Hit the 3 dots at the top right corner, click "Move to" then "Primary"

  • On desktop? Back out of this email then drag and drop this email into the "Primary" tab near the top left of your screen

Apple mail users—tap on our email address at the top of this email (next to "From:" on mobile) and click “Add to VIPs”

Previous Solution

As a refresher, here’s the last question

Imagine you have a 100 gigabyte file with one string per line.

The string consists of integers.

How would you sort all the integers in the file?

Solution

So, the issue here is the size of our file. Let’s assume our computer has 12 gigabytes of RAM.

It’s not possible for us to load a 100 gigabyte file into our main memory (RAM) so our standard sorting algorithms (which assume we can quickly access any piece of our data) are too slow.

Instead, our data will reside in external memory (on our hard disk drive).

The class of sorting algorithms that work with this kind of data is aptly called External Sorting.

External sorting algorithms can be classified into two types: distribution sorting (which resembles quicksort) and external merge sort (which resembles merge sort).

For external merge sort, the file is divided into smaller chunks where each chunk can fit in main memory. Then, each chunk is sorted separately and saved back to external memory. After sorting each individual chunk, the chunks are merged.

Going back to our example, you want to sort a 100 gigabyte file. We have 12 gigabytes of RAM.

Here are the steps in external merge sort.

  1. Divide your file into 10 chunks, each being 10 gigabytes.

  2. Read the first chunk of 10 gigabytes in main memory and sort by a conventional method (quicksort for ex.).

  3. Write the sorted data to disk.

  4. Repeat steps 2 and 3 for the other 9 chunks.

  5. Read the first 1 gigabytes of each sorted chunk into RAM (for a total of 10 gigabytes) and allocate some remaining space (let’s just say 1 gigabyte) for an output buffer.

  6. Perform a 10-way merge between the input buffers (the 1 gig from each sorted chunk) and store the merged chunk in your output buffer.

  7. Whenever the output buffer fills, write it to the final sorted file and then empty it.

  8. Whenever any of our 10 input buffers empties, then we can fill it with the next 1 gigabyte of it’s 10 gigabyte chunk. Repeat until no more data is left.

Want more practice with real FAANG software engineers?

Check out Interviewing.io!

You don’t have to pay anything until you get that job at FAANG!