Data Interview Qs - Array algorithm, noting complexity

InterviewQs

Array algorithm, noting complexity

Python Data Structures Arrays Complexity Big O

Forward this email to a friend or colleague and challenge them to solve it.

Hi, 

Given an array of length N and a number X, write a function to return True if there are two numbers in the array that sum to the given number X.

For example:

  • [1, 2, 3, 4], 7 -> returns True since 3 + 4 sum to 7
  • [1, 6, 3, 5], 5 -> returns False since no *two* numbers sum to 5

For simplicity, you can assume that there are no duplicate numbers in the array. Lastly, be sure to describe the complexity (Big O notation) of your solution, and see if you can come up with something that is at least linear (O(n)).

Our solution will be written in Python for premium users.


 

You’ve accumulated 375 questions since joining our email list. Create a premium account to access detailed solutions to each problem (including this one) + our new Case studies.


Was this email forwarded to you? You can join our list here to receive questions

How did you like today's question?

15411 Boischatel, Montreal, QC, H9H1Y7, Canada
Don't want to get these emails anymore? We'll forgive you if you unsubscribe

Key phrases

Older messages

Removing a trend from time series data

Monday, November 21, 2022

Detrending, Machine Learning, Data Manipulation, Python, Forecast, InterviewQs Removing a trend from time series data Detrending Machine Learning Data Manipulation Python Forecast Forward this email to

Calculating cumulative sales with windowing functions

Friday, November 18, 2022

SQL, Database Querying, Window Function, Cumulative Sum, Subquery, InterviewQs Calculating cumulative sales with windowing functions SQL Database Querying Window Function Cumulative Sum Subquery

Setting up a custom alert system for changes to a URL

Wednesday, November 16, 2022

Python, Data Structures, External Dataset, InterviewQs Setting up a custom alert system for changes to a URL Python Data Structures External Dataset Forward this email to a friend or colleague and

Calculating the Root Mean Squared Error (RMSE) of a model

Monday, November 14, 2022

Python, Data Structures, RMSE, Arrays, InterviewQs Calculating the Root Mean Squared Error (RMSE) of a model Python Data Structures RMSE Arrays Forward this email to a friend or colleague and challenge

Precision, recall, and F-1 scores

Friday, November 11, 2022

Precision, Recall, F1 Score, Machine Learning, InterviewQs Precision, recall, and F-1 scores Precision Recall F1 Score Machine Learning Forward this email to a friend or colleague and challenge them to

You Might Also Like

Retro Recomendo: Music

Sunday, April 28, 2024

Recomendo - issue #408 ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏

Your Phone’s Other Number 📱

Saturday, April 27, 2024

Let's talk about your phone's IMEI number. Here's a version for your browser. Hunting for the end of the long tail • April 27, 2024 Today in Tedium: As you may know, Tedium is a blog and/or

🕹️ How to Play Retro Games for Free on iPhone — Why I Can't Live Without an eReader

Saturday, April 27, 2024

Also: Anker MagGo (Qi2) Power Bank Review, and More! How-To Geek Logo April 27, 2024 📩 Get expert reviews, the hottest deals, how-to's, breaking news, and more delivered directly to your inbox by

Weekend Reading — The Bob Ross of programming

Saturday, April 27, 2024

This week we use coffee tasting as our design practice, get as close to and as far away from the metal as possible, find an easier way to write documentation, discover why Google Search is getting so

Issue #538: All the Jam entries, Panthera 2, and Tristram

Saturday, April 27, 2024

Weekly newsletter about HTML5 Game Development. Is this email not displaying correctly? View it in your browser. Issue #538 - April 26th 2024 If you have anything you want to share with the HTML5 game

Daily Coding Problem: Problem #1424 [Easy]

Saturday, April 27, 2024

Daily Coding Problem Good morning! Here's your coding interview problem for today. This problem was asked by Microsoft. Implement a URL shortener with the following methods: shorten(url) , which

Charted | Countries That Became More Happy (or Unhappy) Since 2010 😅

Saturday, April 27, 2024

Which countries had the highest happiness gains since 2010? Which became sadder? View Online | Subscribe Presented by Voronoi: The App Where Data Tells the Story FEATURED STORY Countries With the

Noonification: What Is E-Waste Hacking?

Saturday, April 27, 2024

Top Tech Content sent at Noon! The first AI-powered startup unlocking the “billionaire economy” for your benefit How are you, @newsletterest1? 🪐 What's happening in tech this week: The

TikTok faces a ban in the US, Tesla profits drop and healthcare data leaks

Saturday, April 27, 2024

Plus: Amazon's new delivery subscription and a deep dive on Rippling View this email online in your browser By Kyle Wiggers Saturday, April 27, 2024 Image Credits: TechCrunch Welcome, folks, to

🐍 New Python tutorials on Real Python

Saturday, April 27, 2024

Hey there, There's always something going on over at realpython.com as far as Python tutorials go. Here's what you may have missed this past week: Write Unit Tests for Your Python Code With