- InstaByte
- Posts
- Did Google really ask this?
Did Google really ask this?
ALSO: SQL Execution Order
Welcome back!
We can’t figure out why Google asked this problem. Let us know if you can.
Here’s what to expect today:
Merge Two Sorted Lists problem
SQL Execution Order
Read time: under 4 minutes
CODING CHALLENGE
Merge Two Sorted Lists
You are given the heads of two sorted linked lists list1
and list2
.
Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists.
Return the head of the merged linked list.
Example:
Input: list1 = [1,2,4], list2 = [1,3,4]
Output: [1,1,2,3,4,4]
Solve the problem here before reading the solution.
PROJECT CHALLENGE
Before we get to the solution, here is a project challenge for you. To participate in this challenge, follow these steps:
Choose one of these projects:
Build your own Git
Build your own Interpreter
Build your own HTTP server.
Start building!
If you need help, go to CodeCrafters and get a step by step guide to build it.
Share a proof of completion by responding to this email and we will invite you to a career chat with Sahil.
SOLUTION
To merge the lists, we'll compare nodes from both lists and add the smaller one to our result list. We'll keep doing this until we've gone through all nodes.
We'll use two pointers, one for each list. We'll also have a pointer for our new merged list. We'll move these pointers as we build our merged list.
If one list ends before the other, we'll just add the rest of the other list to our result.
The time complexity of this solution is O(n + m)
, where n
and m
are the lengths of the two input lists.
COMMUNITY
InstaByte Question Bank
🧠 Help each other by sharing the actual questions you were asked in a recent interview. Use this form to submit your question.
We will share the submitted questions on this weekly newsletter - stay tuned!
Note: Your submission is anonymous.
SYSTEM DESIGN EXPLAINED
SQL Execution Order
In the SQL query shown above, which command is executed first: SELECT, FROM or JOIN?
To answer this question, let's break down the execution order:
FROM customers: This is the first part to be executed. It identifies the primary table, 'customers', from which the data will be retrieved.
JOIN: The JOIN operation is the next to be executed. It combines the rows from the 'customers' table with matching rows from the 'orders' table based on the common column 'customer_id'.
WHERE: The WHERE clause is then applied to filter rows where the order date is after '2022-01-01'.
GROUP BY: The GROUP BY clause is executed next. It groups the results by customer_id.
COUNT: The COUNT aggregate function is applied to count the number of orders for each customer, and the result is aliased as 'order_count'.
SELECT: Finally, the SELECT clause retrieves the specified columns and aggregates from the processed data.
ORDER BY: The last operation is the ORDER BY clause, which sorts the result set based on the 'order_count' column in descending order.
NEWS
This Week in the Tech World
Amazon Tests UK Drone Delivery: Amazon joins trial to test drone deliveries in remote UK locations. The program aims to integrate drones flying beyond visual line of sight into UK airspace.
Ex-Google CEO Bullish on Nvidia: Former Google CEO Eric Schmidt suggests Nvidia as a major AI winner, citing tech giants' plans for massive investments in Nvidia-based AI data centers.
Waymo Doubles Weekly Trips: Alphabet-owned Waymo reports providing over 100,000 paid robotaxi rides per week, double the number from May. San Francisco now serves the most trips among Waymo's operating cities.
OpenAI Partners with Condé Nast: OpenAI teams up with Condé Nast, allowing ChatGPT to display content from magazines like Vogue and The New Yorker. This follows similar deals with other media outlets amid ongoing copyright debates.
Anthropic Faces Copyright Lawsuit: Amazon-backed AI startup Anthropic hit with class-action lawsuit over alleged copyright infringement. Authors claim the company "stole" copyrighted books to train its AI models.
Revolut Valued at $45 Billion: British fintech Revolut reaches $45 billion valuation in secondary share sale. The new valuation comes shortly after the company received a UK banking license with restrictions.
Klarna Expands Banking Services: Klarna launches personal account and cashback rewards in the US and Europe, pushing deeper into banking. The move comes as the company edges closer to a potential IPO.
British Tech Entrepreneur Missing: Mike Lynch, founder of Autonomy, reported missing after superyacht sinks off Sicily coast. The incident occurred during an unexpectedly violent storm.
BONUS
Just for laughs 😏
HELP US
👋 Hi there! We are on a mission to provide as much value as possible for free. If you want this newsletter to remain free, please help us grow by referring your friends:
📌 Share your referral link on LinkedIn or directly with your friends.
📌 Check your referrals status here.
YOUR FEEDBACK
What did you think of this week's email?Your feedback helps us create better emails for you! |
Until next time, take care! 🚀
Cheers,