Find n-th missing element in unsorted array

InterviewQs

Find n-th missing element in unsorted array

Python Data Structures Arrays

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

Suppose you're given an unsorted array, a. The array is intended to have all integer elements between its minimum and maximum, but could be missing some elements. Write a python function to find the n-th missing element in the array.

Consider the array in sorted order, then find the n-th missing number. If the n-th missing number does not exist, you can output 'Does not exist'.

Examples:

    

Input: a = [2, 3, 11, 9], n = 3

Output: 6

Missing elements in array: [4, 5, 6, 7, 8, 10]. So, the 3rd missing element is 6.


    

Input: a = [2, 3, 5], n = 5

Output: 'Does not exist'

Since there is no 5th missing element in the array, we output 'Does not exist' (the only missing element here is 4).



 

Congratulations! You’ve accumulated 162 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

Older messages

Employee survey results

Friday, July 16, 2021

SQL, Database Querying, InterviewQs Employee survey results SQL Database Querying Forward this email to a friend or colleague and challenge them to solve it. You're consulting for a company, and

Consumer complaints on financial products

Monday, July 12, 2021

Data Analysis, Python, Pandas, Data Manipulation, External Dataset, InterviewQs Consumer complaints on financial products Data Analysis Python Pandas Data Manipulation External Dataset Forward this

Subarrays having a sum of p

Saturday, July 10, 2021

Python, Data Structures, Arrays, InterviewQs Subarrays having a sum of p Python Data Structures Arrays Forward this email to a friend or colleague and challenge them to solve it. Suppose you have an

Delivery times

Saturday, July 10, 2021

Data Analysis, Python, Pandas, T-test, InterviewQs Delivery times Data Analysis Python Pandas T-test Forward this email to a friend or colleague and challenge them to solve it. Suppose you are working

State populations

Monday, July 5, 2021

SQL, Database Querying, Window Function, InterviewQs State populations SQL Database Querying Window Function Forward this email to a friend or colleague and challenge them to solve it. Suppose you come

Python Weekly - Issue 511

Thursday, August 5, 2021

View this email in your browser Python Weekly Welcome to issue 511 of Python Weekly. Let's get straight to the links this week. From Our Sponsor SonarLint Free and Open Source IDE Extension for

Google's quantum 'time crystal' is as weird as it sounds

Thursday, August 5, 2021

Windows 365: Hands on... ZDNet Facebook Twitter LinkedIn ZDNet Tech Today August 5, 2021 placeholder Google says it has created a time crystal in a quantum computer, and it's weirder than you can

Several Malware Families Targeting IIS Web Servers With Malicious Modules

Thursday, August 5, 2021

The Hacker News Daily Updates Newsletter cover Cloud Computing For Dummies, 2nd Edition ($21.00 Value) FREE for a Limited Time Get your head--and your business--into the Cloud Download Now Sponsored

Airbnb's Ghost platform

Thursday, August 5, 2021

Airbnb iterates fast. A recent blog from Ryan Brooks, a software engineer at Airbnb, gave us a look under the... Product Hunt Read in browser This newsletter is brought to you by Airbnb's Ghost

Issue 145: APIs and electric car charging stations, The Nuts and Bolts of OAuth 2.0 🔩

Thursday, August 5, 2021

Hi, today we look at the recent EV charging station API vulnerabilities, an OAuth2.0 course in Udemy, Gartner API Hype Cycle, and API path tra APIsecurity.io The Latest API Security News,

wpMail.me issue#523

Thursday, August 5, 2021

wpMail.me wpMail.me issue#523 - The weekly WordPress newsletter. No spam, no nonsense. - August 5, 2021 Is this email not displaying correctly? View it in your browser. News & Articles WordPress

Advanced Manufacturing: The Future of Faster, Better, Cheaper

Thursday, August 5, 2021

FARO to Relocate Manufacturing to US-Based EMS Provider ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌

Web Tools #420 - CSS Tools, Front-end Frameworks, Uncats

Thursday, August 5, 2021

Web Tools Weekly WEB VERSION Issue #420 • August 5, 2021 Advertisement Stock Market Data API The marketstack API offers free stock data in JSON for various ticker symbols. Access real-time and

What to expect from Samsung's next foldable phone

Thursday, August 5, 2021

Now available on your smart speaker and wherever you get your podcasts Apple Podcasts | Spotify | Google Play | iHeart Radio It's Thursday, August 05, 2021. For years, Samsung's Galaxy Note was

Apple store redesign 💻, TikTok stories📱, Star Wars hotel 🏨

Thursday, August 5, 2021

The Apple Store went down for just over an hour on Tuesday and came back with a brand-new look. TLDR Daily Update 2021-08-05 Skiff is Signal for documents (Sponsor) Keep your documents private with