Connect with us

Tech

Google and Amazon love it

Google and Amazon love it

 


Welcome back, Interview Masters!

Today's coding challenge is a favorite from Google and Amazon. See if you can solve it in O(n).

In today's newsletter we'll cover:

Reading time: <4 minutes

Coding Challenge

Longest consecutive sequence

Given an unsorted integer array nums, returns the length of the longest sequence of contiguous elements.

I need to write an algorithm that runs in O(n) time.

Input: Number = [100,4,200,1,3,2]
Output: 4 Explanation: The longest sequence of consecutive elements is [1, 2, 3, 4]So the length is 4. Input: nums = [0,3,7,2,5,8,4,6,0,1]
Output: 9

Please solve the problem here before reading the solution.

Refer and earn $500

Corium helps US tech companies hire the top 1% of developers. Here's how to earn a referral bonus from Corium.

1. Talk to US-based hiring managers (such as your manager or potential developer hires) about Corium.

2. Explain how Corium can help you hire great engineering talent quickly and at low cost.

3. Submit this form indicating that you have spoken to someone about Corium.

4. If you hire someone from Corium, you will get a $500 referral bonus.

Solution

To solve this problem in O(n) time, use a HashSet to store all the numbers in an array, which allows you to check if a number exists in the set in O(1) time.

Iterate through each number in the array. For each number, check if the consecutive number before it (num – 1) is not in the set. If not, it means this number is the beginning of the sequence.

Then we increment the number and check to see if the next consecutive number is in the set, until we find a number that isn't in the set, at which point we'll reach the end of the sequence.

If the length of the current sequence is longer, update the length of the longest sequence.

The time complexity of this solution is O(n) because it iterates over the array once and each HashSet operation takes O(1) time on average.

System Design Description

How to design X (Twitter)?

The main requirements are to post new Tweets, follow users, display a newsfeed of Tweets from followed users, and search.

It uses a microservices architecture with services for newsfeed generation, user information, tweet information, and search. The services communicate over REST or gRPC.

Newsfeed services pre-generate and cache feeds for fast access, they can use ranking algorithms like EdgeRank to prioritize relevant Tweets, and approaches like fan-out on write allow new Tweets to be pushed instantly to followers' feeds.

For data partitioning and scalability, we shard our database using consistent hashing. Cassandra or PostgreSQL can store the core data, and Elasticsearch enables fast searches.

Use object storage such as S3 to store photos and videos, which can then be cached on a CDN for fast delivery.

Learn more about.

news

This week in tech

Apple unveils AI plans: Apple announced an AI push called “Apple Intelligence” that will leverage AI across devices and apps. ChatGPT will be integrated into iOS 18 via Siri. Other updates include custom AI emojis, AI writing tools, and AI enhancements to apps like Photos.

Mistral AI Funding: French AI startup Mistral AI has raised $645 million at a $6 billion valuation. Microsoft is also an investor. Mistral is building large-scale language models similar to GPT to take on OpenAI and become the European champion of generative AI.

Apple Overtakes Microsoft: Fueled by enthusiasm over the artificial intelligence plans announced at WWDC, Apple briefly became the world's most valuable company again on Wednesday, June 12. The company's market cap reached $3.3 trillion, surpassing Microsoft's $3.2 trillion, but the lead did not last until the close of trading.

OpenAI executive hires: OpenAI hired Nextdoor's Sarah Friar as CFO and Planet Labs' Kevin Weil as chief product officer. OpenAI also announced a deal to integrate ChatGPT with Apple's Siri.

Humane for sale: Humane, an AI hardware startup founded by a former Apple designer, is looking for a buyer after its AI Pin device received bad press. The company is in talks with HP and telecommunications companies and has hired an investment bank to advise on a potential deal.

Microsoft Outsources AI: According to Okta CEO Todd McKinnon, Microsoft is effectively outsourcing its best AI research and development to OpenAI and reducing itself to an “AI consultant” role, which could benefit Google's organic AI efforts.

AI in education is booming: Nearly half of U.S. teachers and students now use ChatGPT weekly, and 70% of students approve of AI chatbots in education. Adoption has skyrocketed over the past year, despite concerns about cheating.

Bonus

Just for laughs

Presenting for the win

Hello! Share our referral link with your friends to get some hidden treasures:

Share your referral link on LinkedIn or with your friends to get the treasure faster. You can check your referral status here.

Your feedback

Until next time, take care!

Sources

1/ https://Google.com/

2/ https://www.interviewmaster.io/p/google-amazon-love

The mention sources can contact us to remove/changing this article

What Are The Main Benefits Of Comparing Car Insurance Quotes Online

LOS ANGELES, CA / ACCESSWIRE / June 24, 2020, / Compare-autoinsurance.Org has launched a new blog post that presents the main benefits of comparing multiple car insurance quotes. For more info and free online quotes, please visit https://compare-autoinsurance.Org/the-advantages-of-comparing-prices-with-car-insurance-quotes-online/ The modern society has numerous technological advantages. One important advantage is the speed at which information is sent and received. With the help of the internet, the shopping habits of many persons have drastically changed. The car insurance industry hasn't remained untouched by these changes. On the internet, drivers can compare insurance prices and find out which sellers have the best offers. View photos The advantages of comparing online car insurance quotes are the following: Online quotes can be obtained from anywhere and at any time. Unlike physical insurance agencies, websites don't have a specific schedule and they are available at any time. Drivers that have busy working schedules, can compare quotes from anywhere and at any time, even at midnight. Multiple choices. Almost all insurance providers, no matter if they are well-known brands or just local insurers, have an online presence. Online quotes will allow policyholders the chance to discover multiple insurance companies and check their prices. Drivers are no longer required to get quotes from just a few known insurance companies. Also, local and regional insurers can provide lower insurance rates for the same services. Accurate insurance estimates. Online quotes can only be accurate if the customers provide accurate and real info about their car models and driving history. Lying about past driving incidents can make the price estimates to be lower, but when dealing with an insurance company lying to them is useless. Usually, insurance companies will do research about a potential customer before granting him coverage. Online quotes can be sorted easily. Although drivers are recommended to not choose a policy just based on its price, drivers can easily sort quotes by insurance price. Using brokerage websites will allow drivers to get quotes from multiple insurers, thus making the comparison faster and easier. For additional info, money-saving tips, and free car insurance quotes, visit https://compare-autoinsurance.Org/ Compare-autoinsurance.Org is an online provider of life, home, health, and auto insurance quotes. This website is unique because it does not simply stick to one kind of insurance provider, but brings the clients the best deals from many different online insurance carriers. In this way, clients have access to offers from multiple carriers all in one place: this website. On this site, customers have access to quotes for insurance plans from various agencies, such as local or nationwide agencies, brand names insurance companies, etc. "Online quotes can easily help drivers obtain better car insurance deals. All they have to do is to complete an online form with accurate and real info, then compare prices", said Russell Rabichev, Marketing Director of Internet Marketing Company. CONTACT: Company Name: Internet Marketing CompanyPerson for contact Name: Gurgu CPhone Number: (818) 359-3898Email: [email protected]: https://compare-autoinsurance.Org/ SOURCE: Compare-autoinsurance.Org View source version on accesswire.Com:https://www.Accesswire.Com/595055/What-Are-The-Main-Benefits-Of-Comparing-Car-Insurance-Quotes-Online View photos

ExBUlletin

to request, modification Contact us at Here or [email protected]